以下是我的代码
require_once ROOT_PATH . '/vendor/autoload.php';
use \Workerman\Worker;
use \Workerman\Lib\Timer;
$task = new Worker();
// 开启多少个进程运行定时任务,注意多进程并发问题
$task->count = 1;
$task->name = "trendy-cron-server";
$task->onWorkerStart = function($task)
{
$time_interval = 1;
Timer::add($time_interval, function()
{
echo "task run\n";
});
};
// 运行worker
Worker::runAll();
运行后的结果
2016-06-28 10:39:33 worker exit with status 139
2016-06-28 10:39:35 worker exit with status 139
2016-06-28 10:39:36 worker exit with status 139
2016-06-28 10:39:37 worker exit with status 139
2016-06-28 10:39:39 worker exit with status 139
2016-06-28 10:39:40 worker exit with status 139
2016-06-28 10:39:42 worker exit with status 139
2016-06-28 10:39:43 worker exit with status 139
2016-06-28 10:39:44 worker exit with status 139
2016-06-28 10:39:46 worker exit with status 139
2016-06-28 10:39:47 worker exit with status 139
2016-06-28 10:39:49 worker exit with status 139
2016-06-28 10:39:50 worker exit with status 139
2016-06-28 10:39:51 worker exit with status 139
2016-06-28 10:39:53 worker exit with status 139
2016-06-28 10:39:54 worker exit with status 139
2016-06-28 10:39:56 worker exit with status 139
2016-06-28 10:39:57 worker exit with status 139
2016-06-28 10:39:59 worker exit with status 139
2016-06-28 10:40:00 worker exit with status 139
timer 里面的‘echo "task run\n";’程序没执行,有懂的请帮忙看看,是哪块的问题,多谢了。
php版本是7.0
应该是php7.0的bug,升级下PHP或者降级到PHP5.6试下
试过了php5.6正常,估计真是php7.0的bug