zhamao-framework/src/ZM/Command/Daemon/DaemonCommand.php

26 lines
784 B
PHP
Raw Normal View History

<?php
2021-06-16 00:17:30 +08:00
namespace ZM\Command\Daemon;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
2022-03-13 22:46:22 +08:00
use ZM\Framework;
abstract class DaemonCommand extends Command
{
protected $daemon_file = null;
protected function execute(InputInterface $input, OutputInterface $output): int {
2022-03-13 22:46:22 +08:00
$file = Framework::getProcessState(ZM_PROCESS_MASTER);
if ($file === false || posix_getsid(intval($file["pid"])) === false) {
2021-06-16 00:17:30 +08:00
$output->writeln("<comment>未检测到正在运行的守护进程或框架进程!</comment>");
2022-03-13 22:46:22 +08:00
Framework::removeProcessState(ZM_PROCESS_MASTER);
die();
}
$this->daemon_file = $file;
2021-04-06 01:19:56 +08:00
return 0;
}
}