自定义使用worker服务
class Worker extends Server
{
protected $host = '127.0.0.1';
protected $port = 2346;
protected $option = [
'count' => 4,
'pidFile' => Env::get('runtime_path') . 'worker.pid',
'name' => 'thinkworker'
];
}
运行worker服务器时报
php think server:worker
常量赋值包含无效的表达式
后来发现在$option中赋值不能使用Env::get方法怎么办呢?
class Worker extends Server
{
protected $host = '127.0.0.1';
protected $port = 2346;
protected $option = [];
public function __init() {
$this->option = [
'count' => 4,
'pidFile' => Env::get('runtime_path') . 'worker.pid',
'name' => 'thinkworker'
];
}
}
开始用的__construct() 发现监听不到worker服务,后来发现只能使用__init()方法。