Files
kiri-core/http-server/Events/OnWorkerError.php
T

39 lines
765 B
PHP
Raw Normal View History

2020-08-31 01:27:08 +08:00
<?php
2020-09-02 11:38:47 +08:00
namespace HttpServer\Events;
2020-08-31 01:27:08 +08:00
2020-09-02 17:33:48 +08:00
use Exception;
2020-09-02 11:38:47 +08:00
use HttpServer\Events\Abstracts\Callback;
2020-09-02 17:33:48 +08:00
use Snowflake\Config;
use Snowflake\Exception\ConfigException;
use Swoole\Server;
2020-08-31 01:27:08 +08:00
class OnWorkerError extends Callback
{
/**
2020-09-02 17:33:48 +08:00
* @param Server $server
* @param int $worker_id
* @param int $worker_pid
* @param int $exit_code
* @param int $signal
2020-09-02 19:09:32 +08:00
* @throws Exception
2020-08-31 01:27:08 +08:00
*/
2020-09-02 17:33:48 +08:00
public function onHandler(Server $server, int $worker_id, int $worker_pid, int $exit_code, int $signal)
2020-08-31 01:27:08 +08:00
{
$this->clear($server, $worker_id, self::EVENT_ERROR);
2020-09-02 17:33:48 +08:00
if (!Config::has('email')) {
return;
}
2020-09-03 01:42:39 +08:00
$this->system_mail(print_r([
'$worker_pid' => $worker_pid,
'$worker_id' => $worker_id,
'$exit_code' => $exit_code,
'$signal' => $signal,
], true));
2020-08-31 01:27:08 +08:00
}
}