This commit is contained in:
2021-03-02 19:16:20 +08:00
parent 350ab44283
commit b5d163697b
4 changed files with 79 additions and 24 deletions
+7 -10
View File
@@ -8,16 +8,14 @@ use Database\Connection;
use Exception;
use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\SMTP;
use ReflectionException;
use Snowflake\Abstracts\Config;
use Snowflake\Error\Logger;
use Snowflake\Core\Json;
use Snowflake\Event;
use Snowflake\Exception\ComponentException;
use Snowflake\Exception\ConfigException;
use Snowflake\Exception\NotFindClassException;
use Snowflake\Snowflake;
use Swoole\Coroutine\Server;
use Swoole\Timer;
use Swoole\Process;
use Swoole\Server;
/**
@@ -34,14 +32,14 @@ abstract class Callback extends HttpService
* @param $message
* @throws Exception
*/
protected function clear($server, $worker_id, $message)
protected function clear(Server $server, $worker_id, $message)
{
try {
Snowflake::clearProcessId($server->worker_pid);
$logger = Snowflake::app()->getLogger();
$logger->write($this->_MESSAGE[$message] . $worker_id);
$logger->clear();
/** @var Process $logger */
$logger = Snowflake::app()->get('logger_process');
$logger->write(Json::encode([$this->_MESSAGE[$message] . $worker_id, 'app']));
$this->eventNotify($message);
} catch (\Throwable $exception) {
@@ -156,7 +154,6 @@ abstract class Callback extends HttpService
}
/**
* @throws ConfigException
* @throws ComponentException
+5 -3
View File
@@ -3,6 +3,7 @@
namespace HttpServer;
use HttpServer\Abstracts\Callback;
use HttpServer\Abstracts\HttpService;
use HttpServer\Events\OnClose;
use HttpServer\Events\OnConnect;
@@ -69,7 +70,8 @@ class Server extends HttpService
private array $process = [
'biomonitoring' => Biomonitoring::class
'biomonitoring' => Biomonitoring::class,
'logger_process' => Callback::class
];
private array $params = [];
@@ -99,13 +101,11 @@ class Server extends HttpService
/**
* @param array $configs
* @return Packet|Websocket|Receive|Http|null
* @throws ConfigException
* @throws Exception
*/
public function initCore(array $configs): Packet|Websocket|Receive|Http|null
{
$this->orders($configs);
$this->onProcessListener();
return $this->getServer();
}
@@ -376,6 +376,8 @@ class Server extends HttpService
}
$this->baseServer->set($settings);
$this->onProcessListener();
return $this->baseServer;
}