This commit is contained in:
as2252258@163.com
2021-03-28 16:09:18 +08:00
parent 7ea7b1e36e
commit 86e8ad68e9
11 changed files with 1341 additions and 1145 deletions
+27 -30
View File
@@ -5,12 +5,8 @@ namespace HttpServer;
use Exception;
use ReflectionException;
use Snowflake\Abstracts\Input;
use Snowflake\Event;
use Snowflake\Exception\ComponentException;
use Snowflake\Exception\ConfigException;
use Snowflake\Exception\NotFindPropertyException;
use Snowflake\Snowflake;
/**
@@ -20,40 +16,41 @@ use Snowflake\Snowflake;
class Command extends \Console\Command
{
public string $command = 'sw:server';
public string $command = 'sw:server';
public string $description = 'server start|stop|reload|restart';
public string $description = 'server start|stop|reload|restart';
const ACTIONS = ['start', 'stop', 'restart'];
const ACTIONS = ['start', 'stop', 'restart'];
/**
* @param Input $dtl
* @return string
* @throws Exception
* @throws ConfigException
*/
public function onHandler(Input $dtl): string
{
$manager = Snowflake::app()->getServer();
$manager->setDaemon($dtl->get('daemon', 0));
/**
* @param Input $dtl
* @return string
* @throws Exception
* @throws ConfigException
*/
public function onHandler(Input $dtl): string
{
$manager = Snowflake::app()->getServer();
$manager->setDaemon($dtl->get('daemon', 0));
if (!in_array($dtl->get('action'), self::ACTIONS)) {
return 'I don\'t know what I want to do.';
}
if (!in_array($dtl->get('action'), self::ACTIONS)) {
return 'I don\'t know what I want to do.';
}
if ($manager->isRunner() && $dtl->get('action') == 'start') {
return 'Service is running. Please use restart.';
}
/** @var Shutdown $shutdown */
$shutdown = Snowflake::app()->get('shutdown');
if ($shutdown->isRunning() && $dtl->get('action') == 'start') {
return 'Service is running. Please use restart.';
}
$manager->shutdown();
if ($dtl->get('action') == 'stop') {
return 'shutdown success.';
}
return $manager->start();
}
$shutdown->shutdown();
if ($dtl->get('action') == 'stop') {
return 'shutdown success.';
}
return $manager->start();
}
}