Files
kiri-core/System/Process/Biomonitoring.php
T

56 lines
955 B
PHP
Raw Normal View History

2021-01-08 10:57:07 +08:00
<?php
namespace Snowflake\Process;
2021-03-19 10:31:25 +08:00
use Exception;
2021-04-26 17:34:33 +08:00
use JetBrains\PhpStorm\Pure;
2021-01-08 10:57:07 +08:00
use Snowflake\Snowflake;
use Swoole\Timer;
/**
* Class Biomonitoring
* @package components
*/
class Biomonitoring extends Process
{
2021-04-26 17:34:33 +08:00
/**
* @param \Swoole\Process $process
*/
public function before(\Swoole\Process $process): void
{
// TODO: Implement before() method.
}
/**
* @return string
*/
#[Pure] public function getProcessName(): string
{
// TODO: Implement getProcessName() method.
return get_called_class();
}
2021-01-08 10:57:07 +08:00
/**
* @param \Swoole\Process $process
2021-03-19 10:31:25 +08:00
* @throws Exception
2021-01-08 10:57:07 +08:00
*/
public function onHandler(\Swoole\Process $process): void
{
2021-01-28 11:27:53 +08:00
$server = Snowflake::app()->getSwoole();
2021-01-08 10:57:07 +08:00
Timer::tick(1000, function () use ($server) {
clearstatcache();
if (($size = filesize($server->setting['log_file'])) > 1024000000) {
@unlink($server->setting['log_file']);
Process::kill($server->master_pid, SIGRTMIN);
}
});
}
}