Files
kiri-core/HttpServer/Events/OnShutdown.php
T

45 lines
851 B
PHP
Raw Normal View History

2020-09-02 11:38:47 +08:00
<?php
namespace HttpServer\Events;
use Exception;
2020-09-04 01:05:33 +08:00
use HttpServer\Abstracts\Callback;
2020-09-02 11:38:47 +08:00
use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\SMTP;
2020-09-04 01:05:33 +08:00
use Snowflake\Abstracts\Config;
2020-09-02 11:38:47 +08:00
use Snowflake\Core\JSON;
use Snowflake\Error\Logger;
use Snowflake\Event;
2020-09-02 17:33:48 +08:00
use Snowflake\Exception\ComponentException;
2020-09-02 11:38:47 +08:00
use Snowflake\Exception\ConfigException;
use Snowflake\Snowflake;
2020-09-07 15:54:53 +08:00
use Swoole\Coroutine;
2020-09-02 11:38:47 +08:00
use Swoole\Server;
use Closure;
/**
* Class OnShutdown
* @package HttpServer\Events
*/
class OnShutdown extends Callback
{
/**
* @param Server $server
2020-09-02 19:09:32 +08:00
* @throws ComponentException
2020-09-02 17:33:48 +08:00
* @throws Exception
2020-09-02 11:38:47 +08:00
*/
public function onHandler(Server $server)
{
2020-09-09 18:50:46 +08:00
$this->system_mail('server shutdown~');
2020-09-03 11:39:20 +08:00
$event = Snowflake::app()->getEvent();
2020-09-02 17:33:48 +08:00
if (!$event->exists(Event::SERVER_SHUTDOWN)) {
return;
2020-09-02 11:38:47 +08:00
}
2020-09-02 17:33:48 +08:00
$event->trigger(Event::SERVER_SHUTDOWN);
2020-09-02 11:38:47 +08:00
}
}