/**
  * The index method is the default method called when you access this controller, so we can use this
  * to run the scheduled tasks. Takes an optional URL parameter "tasks", which is a comma separated list of
  * the module names to schedule, plus can contain "notifications" to fire the built in notifications system or
  * "all_modules" to fire every module that declares a scheduled task plugin.
  * If tasks are not specified then everything is run.
  */
 public function index()
 {
     $tm = microtime(true);
     $this->db = new Database();
     $system = new System_Model();
     if (isset($_GET['tasks'])) {
         $tasks = explode(',', $_GET['tasks']);
     } else {
         $tasks = array('notifications', 'all_modules');
     }
     // grab the time before we start, so there is no chance of a record coming in while we run that is missed.
     $currentTime = time();
     if (in_array('notifications', $tasks)) {
         $this->last_run_date = $system->getLastScheduledTaskCheck();
         $this->checkTriggers();
     }
     $tmtask = microtime(true) - $tm;
     if ($tmtask > 5) {
         self::msg("Triggers & notifications scheduled task took {$tmtask} seconds.", 'alert');
     }
     $this->runScheduledPlugins($system, $tasks);
     if (in_array('notifications', $tasks)) {
         $swift = email::connect();
         $this->doRecordOwnerNotifications($swift);
         $this->doDigestNotifications($swift);
     }
     // mark the time of the last scheduled task check, so we can get diffs next time
     $this->db->update('system', array('last_scheduled_task_check' => "'" . date('c', $currentTime) . "'"), array('id' => 1));
     self::msg("Ok!");
     $tm = microtime(true) - $tm;
     if ($tm > 30) {
         self::msg("Scheduled tasks for " . implode(', ', $tasks) . " took {$tm} seconds.", 'alert');
     }
 }
示例#2
0
 public function kill($pid)
 {
     // kill the command by pid
     // don't delete from db as the command might not really be dead
     // let the index run it's check to test
     $cmd = new System_Model();
     $cmd->kill($pid);
     url::redirect('command');
 }
示例#3
0
 /**
  * Action called when an formal upgrade is required.
  */
 public function upgrade()
 {
     $upgrader = new Upgrade_Model();
     try {
         $view = new View('upgrade');
         $this->template->title = 'Indicia Upgrade';
         $upgrader->run();
     } catch (Exception $e) {
         $view->error = $e->getMessage();
     }
     $system = new System_Model();
     $view->db_version = $system->getVersion();
     $view->app_version = kohana::config('version.version');
     $view->pgUserScriptsToBeApplied = $upgrader->pgUserScriptsToBeApplied;
     $view->slowScriptsToBeApplied = $upgrader->slowScriptsToBeApplied;
     $this->template->content = $view;
 }