Open Source Billing
This commit is contained in:
35
modules/task/classes/Task/Task/Listactive.php
Normal file
35
modules/task/classes/Task/Task/Listactive.php
Normal file
@@ -0,0 +1,35 @@
|
||||
<?php defined('SYSPATH') or die('No direct access allowed.');
|
||||
|
||||
/**
|
||||
* List all Active Tasks defined in the DB
|
||||
*
|
||||
* @package Task
|
||||
* @category Tasks
|
||||
* @author Deon George
|
||||
* @copyright (c) 2009-2013 Open Source Billing
|
||||
* @license http://dev.osbill.net/license.html
|
||||
*/
|
||||
class Task_Task_Listactive extends Task {
|
||||
protected function _execute(array $params) {
|
||||
$output = '';
|
||||
|
||||
$output .= sprintf('%2s %30s %21s %21s %40s',
|
||||
'ID','Command','Last Run','Next Run','Description');
|
||||
$output .= "\n";
|
||||
|
||||
foreach (ORM::factory('Task')->list_active() as $t) {
|
||||
$output .= sprintf('%2s %30s %21s %21s %40s',
|
||||
$t['task']->id,
|
||||
$t['task']->command,
|
||||
$t['task']->display('date_run'),
|
||||
Config::datetime($t['next']),
|
||||
$t['task']->display('description')
|
||||
);
|
||||
|
||||
$output .= "\n";
|
||||
};
|
||||
|
||||
echo $output;
|
||||
}
|
||||
}
|
||||
?>
|
46
modules/task/classes/Task/Task/Run.php
Normal file
46
modules/task/classes/Task/Task/Run.php
Normal file
@@ -0,0 +1,46 @@
|
||||
<?php defined('SYSPATH') or die('No direct access allowed.');
|
||||
|
||||
/**
|
||||
* Run active tasks according to their CRON schedule
|
||||
*
|
||||
* @package Task
|
||||
* @category Tasks
|
||||
* @author Deon George
|
||||
* @copyright (c) 2009-2013 Open Source Billing
|
||||
* @license http://dev.osbill.net/license.html
|
||||
*/
|
||||
class Task_Task_Run extends Task {
|
||||
protected function _execute(array $params) {
|
||||
if ($params['id']) {
|
||||
$to = ORM::factory('Task',$params['id']);
|
||||
|
||||
if ($to->loaded()) {
|
||||
if (! $to->status)
|
||||
throw new Minion_Exception_InvalidTask('Task :task (:name) NOT active',array(':task'=>$params['id'],':name'=>$to->name));
|
||||
|
||||
if (! Kohana::$config->load('debug')->task_sim)
|
||||
$to->run($params['force']);
|
||||
else
|
||||
printf('Would Run task: (%s) %s',$params['id'],$to->name);
|
||||
|
||||
echo "\n";
|
||||
|
||||
} else
|
||||
throw new Minion_Exception_InvalidTask('Unknown task :task',array(':task'=>$params['id']));
|
||||
|
||||
} else {
|
||||
$tlo = ORM::factory('Task');
|
||||
$t = time();
|
||||
|
||||
foreach ($tlo->list_active() as $to)
|
||||
if ($to['next'] < $t) {
|
||||
if (! Kohana::$config->load('debug')->task_sim)
|
||||
$to['task']->run();
|
||||
else
|
||||
printf('Would Run task: (%s) %s',$to['task']->id,$to['task']->name);
|
||||
echo "\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
Reference in New Issue
Block a user