由于項(xiàng)目上需要在業(yè)務(wù)執(zhí)行完成后才退出,本人的實(shí)現(xiàn)方式是在一個叫master的子進(jìn)程中監(jiān)聽業(yè)務(wù)進(jìn)程,在所有業(yè)務(wù)完成后再退出master的子進(jìn)程,但由于框架的退出時是不分次序直接退出,導(dǎo)致業(yè)務(wù)進(jìn)程還在執(zhí)行,而master的子進(jìn)程已經(jīng)退出,無法完成完整業(yè)務(wù)
本人在做優(yōu)雅退出時是通過重寫stopAII實(shí)現(xiàn),測試發(fā)現(xiàn)派生的子類的stopAII并未執(zhí)行,檢查過框架源碼理應(yīng)能正常執(zhí)行,能否幫忙看看呢
public static function stopAll($code = 0, $log = '') {
Log::info('child Worker', 'stopAll');
if (\DIRECTORY_SEPARATOR === '/' && static::$_masterPid === posix_getpid()) {
Log::info('master', 'stopAll');
parent::stopAll($code, $log);
} else {
if ($log) {
static::log($log);
}
static::$_status = static::STATUS_SHUTDOWN;
// Execute exit.
$workers = array_reverse(static::$_workers);
foreach ($workers as $worker) {
if (!$worker->stopping) {
$worker->stop();
$worker->stopping = true;
}
}
if (!static::$_gracefulStop) {
static::$_workers = array();
if (static::$globalEvent) {
static::$globalEvent->destroy();
}
try {
Log::info('exit Worker', '111111111111');
exit($code);
} catch (\Exception $e) {
}
}
}
}
@walkor