This commit is contained in:
2021-03-01 15:09:36 +08:00
parent 08b21aeb7b
commit 62e2153446
2 changed files with 425 additions and 416 deletions
+8 -2
View File
@@ -7,8 +7,10 @@ namespace HttpServer;
use Exception;
use JetBrains\PhpStorm\Pure;
use Snowflake\Abstracts\Config;
use Snowflake\Abstracts\Input;
use Snowflake\Exception\ComponentException;
use Snowflake\Exception\ConfigException;
use Snowflake\Snowflake;
use Swoole\WebSocket\Server;
@@ -63,11 +65,15 @@ trait Action
/**
* @return mixed
* @throws ComponentException
* @throws ConfigException
*/
private function getPidFile(): string
{
return Snowflake::app()->getSwoole()->setting['pid_file'];
$settings = Config::get('settings', false, []);
if (!isset($settings['pid_file'])) {
return PID_PATH;
}
return $settings['pid_file'];
}
+4 -1
View File
@@ -29,6 +29,9 @@ use Swoole\Process;
use Swoole\Runtime;
use co;
defined('PID_PATH') or define('PID_PATH', APP_PATH . 'storage/server.pid');
/**
* Class Server
* @package HttpServer
@@ -370,7 +373,7 @@ class Server extends HttpService
$this->baseServer = new $class($config['host'], $config['port'], SWOOLE_PROCESS, $config['mode']);
$settings['daemonize'] = $this->daemon;
if (!isset($settings['pid_file'])) {
$settings['pid_file'] = APP_PATH . 'storage/server.pid';
$settings['pid_file'] = PID_PATH;
}
if ($this->baseServer instanceof Websocket) {
$this->onLoadWebsocketHandler();