swoole-framwork/core/init/TestProcess.php
2024-05-20 11:51:07 +08:00

30 lines
897 B
PHP
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
namespace Core\init;
use Swoole\Process;
use Core\helper\FileHelper;
class TestProcess
{
private $md5file;
public function run()
{
$process = new Process(function() {
while (true) {
sleep(3);
$md5Value = FileHelper::getFileMd5(ROOT_PATH.'/app/*','/app/config');
if ($this->md5file==''){
$this->md5file = $md5Value;
continue;
}
if (strcmp($this->md5file,$md5Value)!==0){
echo "代码有改动重新加载ing".PHP_EOL;
$getPid = intval(file_get_contents("./ttt.pid"));
Process::kill($getPid,SIGUSR1);
$this->md5file = $md5Value;
echo "重新加载ed".PHP_EOL;
}
}
});
return $process;
}
}