问题描述
我正在实现一个基于 Swoole 模块的 php 并行任务脚本,该模块用作守护程序。
是否可以使用 Swoole 函数代替 pcntl_signal() 来处理进程信号?
<?php
declare(strict_types=1);
declare(ticks=1);
use Swoole\Coroutine as Co;
$stopCommand = false;
$sigHandler = static function (int $sig) use (&$stopCommand)
{
switch ($sig) {
case SIGTERM:
$stopCommand = true;
break;
}
};
pcntl_signal(SIGTERM,$sigHandler);
Co\run(function() use (&$stopCommand) {
$results = [];
while(true) {
//go(static function () use (&$results,&$stopCommand) {}
co::sleep(1);
if(!$results && $stopCommand) {
break;
}
}
});
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)