public static function runInternal($serviceName, $service = null) { if (is_null($service)) { $service = Setting::get('services.list.' . $serviceName); } if ($service) { if ($service['instance'] == 'single') { $running = ServiceManager::getRunningInstance($service['name']); if (count($running) > 0) { if ($service['singleInstanceMode'] == 'wait') { return false; } else { ServiceManager::kill($service['name']); } } } $id = ServiceManager::initInstance(); $logPath = ServiceManager::getLogPath($serviceName, $id); $command = "runLog \"{$logPath}\" php yiic.php service execute --id={$id}"; $pid = ServiceManager::process($command); if (!empty($pid)) { $service['pid'] = $pid[0]; ServiceManager::sendMsg($id, $service); return $id; } else { return false; } } }