30 lines
897 B
PHP
30 lines
897 B
PHP
<?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;
|
||
}
|
||
} |