public function actionStartDaemon() { while (true) { $services = Setting::get('services.list', [], true); $curTime = time(); foreach ($services as $name => $service) { $lastRun = strtotime(@$service['lastRun']); if ($service['schedule'] != 'manual') { switch ($service['schedule']) { case "day": $period = $service['period'] * 86400; break; case "hour": $period = $service['period'] * 3600; break; case "minute": $period = $service['period'] * 60; break; } if (!isset($service['lastRun']) || abs($curTime - $lastRun) % $period == 0) { ServiceManager::runInternal($serviceName, $service); } } else { ServiceManager::runInternal($serviceName, $service); } } sleep(1); } }
public function actionStart($n) { ServiceManager::runInternal($n); }
public static function run($serviceName, $params = null) { $service = Setting::get('services.list.' . $serviceName); if ($service) { if (!is_null($params)) { $service['params'] = $params; } return ServiceManager::runInternal($serviceName, $service); } }