冬天的快乐
时间:2017-11-04 21:01:48来源:杰瑞文章网点击:作文字数:600字
作文导读:swoole 官方明确 swoole 自定义进程 addProcess 不支持热重启,但是换个思路可以实现
public function main(){
$this->server = new Server("0.0.0.0",20000);
$this->server->set([
"worker_num"=>2,
"daemonize"=>true,
"reload_async"=>true,
]);
$this->startProcess($this->server);
foreach ($this->events as $event){
$this->server->on($event,[$this,$event]);
}
$this->server->start();
}
public function startProcess(Server $server){
$server->addProcess(new Process(function(Process $process){
swoole_set_process_name("z:process");
$run = true;
require "./test.php";
pcntl_signal(SIGUSR1,function ($signo){
file_put_contents("/data/wwwroot/php-cli/process.log",time()." {$signo}n",FILE_APPEND);
require "./test.php";
});
while($run){
pcntl_signal_dispatch();
test();
}
}));
}
// 通过外部发送 SIGUSR1 实现杀死自定义进程,然后swoole的manager 会重新拉起一个新的Process.. 并不会丢失原有的业务。。
swoole 官方明确 swoole 自定义进程 addProcess 不支持热重启,但是换个思路可以实现
public function main(){
$this->server = new Server("0.0.0.0",20000);
$this->server->set([
"worker_num"=>2,
"daemonize"=>true,
"reload_async"=>true,
]);
$this->startProcess($this->server);
foreach ($this->events as $event){
$this->server->on($event,[$this,$event]);
}
$this->server->start();
}
public function startProcess(Server $server){
$server->addProcess(new Process(function(Process $process){
swoole_set_process_name("z:process");
$run = true;
require "./test.php";
pcntl_signal(SIGUSR1,function ($signo){
file_put_contents("/data/wwwroot/php-cli/process.log",time()." {$signo}n",FILE_APPEND);
require "./test.php";
});
while($run){
pcntl_signal_dispatch();
test();
}
}));
}
// 通过外部发送 SIGUSR1 实现杀死自定义进程,然后swoole的manager 会重新拉起一个新的Process.. 并不会丢失原有的业务。。
冬天的快乐一文由杰瑞文章网免费提供,本站为公益性作文网站,此作文为网上收集或网友提供,版权归原作者所有,如果侵犯了您的权益,请及时与我们联系,我们会立即删除!
杰瑞文章网友情提示:请不要直接抄作文用来交作业。你可以学习、借鉴、期待你写出更好的作文。
说说你对这篇作文的看法吧