コード例 #1
0
ファイル: ServiceCommand.php プロジェクト: reggi49/plansys
 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);
     }
 }
コード例 #2
0
ファイル: ServiceController.php プロジェクト: alfhan/plansys
 public function actionStart($n)
 {
     ServiceManager::runInternal($n);
 }
コード例 #3
0
ファイル: ServiceManager.php プロジェクト: rizabudi/plansys
 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);
     }
 }