00001 <?php
00002
00003
00004
00005
00006 class SchedulerBaseController extends ControllerBase {
00007
00008
00009
00010
00011
00012 public function get_routes() {
00013 $ret = array(
00014 'process' => new ExactMatchRoute('scheduler/process', $this, 'scheduler_process', new ConsoleOnlyRenderDecorator()),
00015 'test' => new ExactMatchRoute('scheduler/test', $this, 'scheduler_test', new ConsoleOnlyRenderDecorator()),
00016 'watchdog' => new ExactMatchRoute('scheduler/watchdog', $this, 'scheduler_watchdog', new ConsoleOnlyRenderDecorator())
00017 );
00018 return $ret;
00019 }
00020
00021
00022
00023
00024 public function before_action() {
00025 Load::models('scheduler');
00026 }
00027
00028
00029
00030
00031
00032
00033 public function action_scheduler_process($page_data) {
00034 $task = Scheduler::get_next_task();
00035 if ($task) {
00036 $cmd = CommandsFactory::create_command('scheduler', 'process', $task);
00037 $page_data->status = $cmd->execute();
00038 }
00039 }
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051 public function action_scheduler_watchdog($page_data) {
00052 $cmd = CommandsFactory::create_command('scheduler', 'cleanup', false);
00053 $page_data->status = $cmd->execute();
00054 }
00055
00056
00057
00058
00059
00060
00061
00062
00063 public function action_scheduler_test($page_data) {
00064 sleep(0.5 * Date::ONE_MINUTE);
00065 }
00066 }