Skip to content

Commit

Permalink
完善注释
Browse files Browse the repository at this point in the history
  • Loading branch information
liu21st committed Jul 3, 2018
1 parent 6104c15 commit b00180c
Showing 1 changed file with 42 additions and 1 deletion.
43 changes: 42 additions & 1 deletion src/command/Swoole.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public function configure()
{
$this->setName('swoole')
->addArgument('action', Argument::OPTIONAL, "start|stop|restart|reload", 'start')
->addOption('daemon', 'd', Option::VALUE_NONE, 'daemonize.')
->addOption('daemon', 'd', Option::VALUE_NONE, 'Run the swoole server in daemon mode.')
->setDescription('Swoole HTTP Server for ThinkPHP');
}

Expand All @@ -51,6 +51,11 @@ public function execute(Input $input, Output $output)
}
}

/**
* 启动server
* @access protected
* @return void
*/
protected function start()
{
$pid = $this->getMasterPid();
Expand Down Expand Up @@ -80,6 +85,11 @@ protected function start()
$swoole->start();
}

/**
* 柔性重启server
* @access protected
* @return void
*/
protected function reload()
{
// 柔性重启使用管理PID
Expand All @@ -95,6 +105,11 @@ protected function reload()
$this->output->writeln('> success');
}

/**
* 停止server
* @access protected
* @return void
*/
protected function stop()
{
$pid = $this->getMasterPid();
Expand All @@ -112,6 +127,11 @@ protected function stop()
$this->output->writeln('> success');
}

/**
* 重启server
* @access protected
* @return void
*/
protected function restart()
{
$pid = $this->getMasterPid();
Expand All @@ -123,6 +143,11 @@ protected function restart()
$this->start();
}

/**
* 获取主进程PID
* @access protected
* @return int
*/
protected function getMasterPid()
{
$masterPid = Cache::get('swoole_master_pid');
Expand All @@ -141,6 +166,11 @@ protected function getMasterPid()
return $masterPid;
}

/**
* 获取管理进程PID
* @access protected
* @return int
*/
protected function getManagerPid()
{
$managerPid = Cache::get('swoole_manager_pid');
Expand All @@ -159,6 +189,11 @@ protected function getManagerPid()
return $managerPid;
}

/**
* 删除PID文件
* @access protected
* @return void
*/
protected function removePid()
{
$masterPid = $this->config['pid_file'];
Expand All @@ -177,6 +212,12 @@ protected function removePid()
Cache::rm('swoole_manager_pid');
}

/**
* 判断PID是否在运行
* @access protected
* @param int $pid
* @return bool
*/
protected function isRunning($pid)
{
if (empty($pid)) {
Expand Down

0 comments on commit b00180c

Please sign in to comment.