mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-17 23:13:15 +00:00
Cleanup after merge
This commit is contained in:
@@ -55,8 +55,7 @@ class task_Scheduler
|
||||
|
||||
protected static function get_connection()
|
||||
{
|
||||
require dirname(__FILE__) . '/../../../config/connexion.inc';
|
||||
return(appbox::get_instance()->get_connection());
|
||||
return appbox::get_instance(\bootstrap::getCore())->get_connection();
|
||||
}
|
||||
|
||||
public function run($input=null, OutputInterface $output = null) //, $log = true, $log_tasks = true)
|
||||
@@ -66,7 +65,7 @@ class task_Scheduler
|
||||
require_once dirname(__FILE__) . '/../../bootstrap.php';
|
||||
$this->input = $input;
|
||||
$this->output = $output;
|
||||
$appbox = appbox::get_instance();
|
||||
$appbox = appbox::get_instance(\bootstrap::getCore());
|
||||
$registry = $appbox->get_registry();
|
||||
|
||||
$nullfile = '';
|
||||
@@ -122,7 +121,7 @@ class task_Scheduler
|
||||
|
||||
$logdir = $registry->get('GV_RootPath') . 'logs/';
|
||||
|
||||
$conn = appbox::get_instance()->get_connection();
|
||||
$conn = appbox::get_instance(\bootstrap::getCore())->get_connection();
|
||||
|
||||
$taskPoll = array(); // the poll of tasks
|
||||
|
||||
@@ -184,7 +183,7 @@ class task_Scheduler
|
||||
sleep(1);
|
||||
try
|
||||
{
|
||||
$conn = appbox::get_instance()->get_connection();
|
||||
$conn = appbox::get_instance(\bootstrap::getCore())->get_connection();
|
||||
}
|
||||
catch(ErrorException $e)
|
||||
{
|
||||
|
@@ -153,22 +153,9 @@ class task_manager
|
||||
}
|
||||
|
||||
public function get_scheduler_state()
|
||||
{
|
||||
$sql = "SELECT schedstatus,
|
||||
UNIX_TIMESTAMP()-UNIX_TIMESTAMP(schedqtime) AS schedqdelay, schedpid
|
||||
FROM sitepreff";
|
||||
$stmt = $this->appbox->get_connection()->prepare($sql);
|
||||
$stmt->execute();
|
||||
$row = $stmt->fetch(PDO::FETCH_ASSOC);
|
||||
$stmt->closeCursor();
|
||||
|
||||
return $row;
|
||||
}
|
||||
|
||||
public function get_scheduler_state2()
|
||||
{
|
||||
$pid = NULL;
|
||||
$appbox = appbox::get_instance();
|
||||
$appbox = appbox::get_instance(\bootstrap::getCore());
|
||||
$lockdir = $appbox->get_registry()->get('GV_RootPath') . 'tmp/locks/';
|
||||
if( ($schedlock = fopen( $lockdir . 'scheduler.lock', 'a+')) )
|
||||
{
|
||||
|
@@ -206,79 +206,11 @@ switch ($parm['action'])
|
||||
|
||||
$output = $ret->saveXML();
|
||||
break;
|
||||
/*
|
||||
case 'PINGSCHEDULER':
|
||||
$lockdir = $registry->get('GV_RootPath') . 'tmp/locks/';
|
||||
|
||||
$ret = new DOMDocument("1.0", "UTF-8");
|
||||
$ret->standalone = true;
|
||||
$ret->preserveWhiteSpace = false;
|
||||
$root = $ret->appendChild($ret->createElement("result"));
|
||||
$root->appendChild($ret->createCDATASection(var_export(array(), true)));
|
||||
|
||||
$h = "";
|
||||
$dat = date("H:i:s");
|
||||
|
||||
|
||||
$root->setAttribute('time', $dat);
|
||||
|
||||
$task_manager = new task_manager($appbox);
|
||||
$scheduler_state = $task_manager->get_scheduler_state();
|
||||
|
||||
$schedstatus = $scheduler_state['schedstatus'];
|
||||
$schedqdelay = $scheduler_state['schedqdelay'];
|
||||
$schedpid = $scheduler_state['schedpid'];
|
||||
|
||||
$root->setAttribute('status', $schedstatus);
|
||||
$root->setAttribute('qdelay', $schedqdelay);
|
||||
|
||||
$schedlock = fopen($lockfile = ($lockdir . 'scheduler.lock'), 'a+');
|
||||
if (flock($schedlock, LOCK_SH | LOCK_NB) != true)
|
||||
{
|
||||
$root->setAttribute('locked', '1');
|
||||
}
|
||||
else
|
||||
{
|
||||
$root->setAttribute('locked', '0');
|
||||
}
|
||||
if ($schedpid > 0)
|
||||
$root->setAttribute('pid', $schedpid);
|
||||
else
|
||||
$root->setAttribute('pid', '');
|
||||
|
||||
foreach ($task_manager->get_tasks() as $task)
|
||||
{
|
||||
$task_node = $root->appendChild($ret->createElement("task"));
|
||||
$task_node->setAttribute('id', $task->get_task_id());
|
||||
$task_node->setAttribute('status', $task->get_status());
|
||||
$task_node->setAttribute('active', $task->is_active());
|
||||
$task_node->setAttribute('crashed', $task->get_crash_counter());
|
||||
$task_node->setAttribute('completed', $task->get_completed_percentage());
|
||||
|
||||
$task_node->setAttribute('runner', $task->get_runner());
|
||||
if ($task->is_running())
|
||||
{
|
||||
$task_node->setAttribute('running', '1');
|
||||
$task_node->setAttribute('pid', $task->get_pid());
|
||||
}
|
||||
else
|
||||
{
|
||||
$task_node->setAttribute('running', '0');
|
||||
$task_node->setAttribute('pid', '');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$output = $ret->saveXML();
|
||||
|
||||
|
||||
break;
|
||||
*/
|
||||
case 'PINGSCHEDULER_JS':
|
||||
$ret = array('time'=> date("H:i:s") );
|
||||
|
||||
$task_manager = new task_manager($appbox);
|
||||
$ret['scheduler'] = $task_manager->get_scheduler_state2();
|
||||
$ret['scheduler'] = $task_manager->get_scheduler_state();
|
||||
|
||||
$ret['tasks'] = array();
|
||||
|
||||
|
Reference in New Issue
Block a user