Files
kiri-core/HttpServer/Command.php
T

52 lines
873 B
PHP
Raw Normal View History

2020-09-03 00:15:57 +08:00
<?php
namespace HttpServer;
2020-09-07 18:11:36 +08:00
use Exception;
use Snowflake\Abstracts\Input;
2020-09-03 00:15:57 +08:00
use Snowflake\Exception\ComponentException;
2020-09-07 15:19:13 +08:00
use Snowflake\Exception\ConfigException;
2020-09-03 00:15:57 +08:00
use Snowflake\Snowflake;
/**
* Class Command
* @package HttpServer
*/
class Command extends \Console\Command
{
public $command = 'server';
public $description = 'server start|stop|reload|restart';
/**
2020-09-07 18:11:36 +08:00
* @param Input $dtl
* @throws ConfigException
* @throws Exception
2020-09-03 00:15:57 +08:00
*/
2020-09-07 18:11:36 +08:00
public function onHandler(Input $dtl)
2020-09-03 00:15:57 +08:00
{
2020-09-07 18:11:36 +08:00
$manager = Snowflake::app()->server;
$manager->setDaemon($dtl->get('daemon', 0));
switch ($dtl->get('action')) {
2020-09-07 15:19:13 +08:00
case 'stop':
2020-09-07 18:11:36 +08:00
$manager->shutdown();
break;
case 'restart':
$manager->shutdown();
$manager->start();
2020-09-07 15:19:13 +08:00
break;
case 'start':
2020-09-07 18:11:36 +08:00
$manager->start();
break;
2020-09-07 15:19:13 +08:00
default:
2020-09-08 10:55:06 +08:00
$this->error('I don\'t know what I want to do.');
2020-09-07 15:19:13 +08:00
}
2020-09-03 00:15:57 +08:00
}
}