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

50 lines
871 B
PHP
Raw Normal View History

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