新增守护控制选项

This commit is contained in:
JaguarJack
2020-07-09 21:56:17 +08:00
parent c84d5a2a17
commit b8de40a60f
2 changed files with 47 additions and 16 deletions

View File

@@ -65,6 +65,11 @@ class Master
*/
protected $master_start_at;
/**
* @var bool
*/
protected $daemon = false;
// 版本
const VERSION = '1.0.0';
@@ -82,7 +87,9 @@ class Master
public function start()
{
// 守护进程
//Process::daemon(true, false);
if ($this->daemon) {
Process::daemon(true, false);
}
// alarm 信号
// Process::alarm(1000 * 1000);
// 1s 调度一次
@@ -129,7 +136,7 @@ class Master
{
return function () {
$schedule = new Schedule();
$schedule->command('catch:cache')->everyTenSeconds();
$schedule->command('catch:cache')->everyThirtySeconds();
foreach ($schedule->getCronTask() as $cron) {
if ($cron->can()) {
@@ -243,6 +250,8 @@ class Master
$this->initLog();
file_put_contents($this->getSaveProcessStatusFile(), '');
$this->createTable();
}
@@ -268,4 +277,17 @@ class Master
'default' => 'schedule',
], 'log');
}
/**
* 开启 debug
*
* @time 2020年07月09日
* @return $this
*/
public function daemon()
{
$this->daemon = true;
return $this;
}
}