public static function UpdateTaskLastExecutionTime($task) { if (self::$s_instance === null) { self::$s_instance = new self(); } self::$s_instance->update($task['unique_id']); }
public static function QueryState(TaskEnvironment $env) { $state = ServiceState::Good; $lastIteration = ServiceState::GetLastIterationTime(); if ($lastIteration < time() - 60 * 60) { $state = ServiceState::Warning; } if ($lastIteration < time() - 12 * 60 * 60) { $state = ServiceState::Error; } return array('name' => 'Service Monitor', 'description' => 'Monitors the services run-time and distributes updates by e-mail in case of any warnings or errors.', 'state' => $state, 'subtasks' => array(array('name' => 'Service Iteration', 'date' => ServiceState::GetLastIterationTime(), 'value' => '\\o/'))); }
private function runTask($task) { Info('Running task "' . implode('::', $task['callback']) . '" (id: ' . $task['unique_id'] . ').'); $taskStart = microtime(true); $instance = new $task['callback'][0](TaskEnvironment::GetInstance(), $task); call_user_func(array($instance, $task['callback'][1])); Info('Ran task "' . implode('::', $task['callback']) . ' in ' . sprintf('%.2f', (microtime(true) - $taskStart) * 1000) . 'ms.'); ServiceState::UpdateTaskLastExecutionTime($task); }