public function processRename($serv, $worker_id)
{
global $argv;
$worker_num = isset($serv->setting['worker_num']) ? $serv->setting['worker_num'] : 1;
$task_worker_num = isset($serv->setting['task_worker_num']) ? $serv->setting['task_worker_num'] : 0;
if ($worker_id >= $worker_num) {
swoole_set_process_name("php {$argv[0]}: task");
} else {
swoole_set_process_name("php {$argv[0]}: worker");
// 定时保存统计数据
if ($worker_id == 0) {
$that =& $this;
$serv->tick($this->write_period_length, function ($id) use($that) {
// echo 'tick one'.PHP_EOL;
$that->writeStatisticsToDisk();
$that->writeLogToDisk();
});
$datapath = Config::$dataPath;
$expireTime = $this->expired_time;
$serv->tick($this->clear_period_length, function ($id) use($datapath, $expireTime, $that) {
// echo 'tick two'.PHP_EOL;
$that->clearDisk($datapath . $this->statisticDir, $expireTime);
$that->clearDisk($datapath . $this->logDir, $expireTime);
});
}
}
usleep($worker_id * 50000);
//保证顺序输出格式
echo str_pad($serv->master_pid, self::$_maxMasterPidLength + 2), str_pad($serv->manager_pid, self::$_maxManagerPidLength + 2), str_pad($serv->worker_id, self::$_maxWorkerIdLength + 2), str_pad($serv->worker_pid, self::$_maxWorkerIdLength), "\n";
}