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

40 lines
657 B
PHP
Raw Normal View History

2020-08-31 01:27:08 +08:00
<?php
2020-10-29 18:17:25 +08:00
declare(strict_types=1);
2020-08-31 01:27:08 +08:00
2020-09-02 11:38:47 +08:00
namespace HttpServer\Events;
2020-08-31 01:27:08 +08:00
2020-09-04 01:05:33 +08:00
use HttpServer\Abstracts\Callback;
2020-08-31 01:27:08 +08:00
use Snowflake\Event;
use Snowflake\Snowflake;
use Swoole\Server;
/**
* Class OnManagerStop
2020-09-02 11:38:47 +08:00
* @package HttpServer\Events
2020-08-31 01:27:08 +08:00
*/
class OnManagerStop extends Callback
{
/**
* @param $server
* @throws \Exception
*/
public function onHandler(Server $server)
{
$this->warning('manager stop.');
2020-09-03 11:39:20 +08:00
$events = Snowflake::app()->event;
2020-09-18 21:17:44 +08:00
$events->trigger(Event::SERVER_MANAGER_STOP, [$server]);
2020-08-31 01:27:08 +08:00
2020-10-14 10:43:43 +08:00
$runPath = storage(null, 'worker');
foreach (glob($runPath . '/*') as $item) {
if (!file_exists($item)) {
continue;
}
@unlink($item);
}
2020-08-31 01:27:08 +08:00
}
}