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()
|
protected static function get_connection()
|
||||||
{
|
{
|
||||||
require dirname(__FILE__) . '/../../../config/connexion.inc';
|
return appbox::get_instance(\bootstrap::getCore())->get_connection();
|
||||||
return(appbox::get_instance()->get_connection());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function run($input=null, OutputInterface $output = null) //, $log = true, $log_tasks = true)
|
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';
|
require_once dirname(__FILE__) . '/../../bootstrap.php';
|
||||||
$this->input = $input;
|
$this->input = $input;
|
||||||
$this->output = $output;
|
$this->output = $output;
|
||||||
$appbox = appbox::get_instance();
|
$appbox = appbox::get_instance(\bootstrap::getCore());
|
||||||
$registry = $appbox->get_registry();
|
$registry = $appbox->get_registry();
|
||||||
|
|
||||||
$nullfile = '';
|
$nullfile = '';
|
||||||
@@ -122,7 +121,7 @@ class task_Scheduler
|
|||||||
|
|
||||||
$logdir = $registry->get('GV_RootPath') . 'logs/';
|
$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
|
$taskPoll = array(); // the poll of tasks
|
||||||
|
|
||||||
@@ -184,7 +183,7 @@ class task_Scheduler
|
|||||||
sleep(1);
|
sleep(1);
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
$conn = appbox::get_instance()->get_connection();
|
$conn = appbox::get_instance(\bootstrap::getCore())->get_connection();
|
||||||
}
|
}
|
||||||
catch(ErrorException $e)
|
catch(ErrorException $e)
|
||||||
{
|
{
|
||||||
|
@@ -153,22 +153,9 @@ class task_manager
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function get_scheduler_state()
|
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;
|
$pid = NULL;
|
||||||
$appbox = appbox::get_instance();
|
$appbox = appbox::get_instance(\bootstrap::getCore());
|
||||||
$lockdir = $appbox->get_registry()->get('GV_RootPath') . 'tmp/locks/';
|
$lockdir = $appbox->get_registry()->get('GV_RootPath') . 'tmp/locks/';
|
||||||
if( ($schedlock = fopen( $lockdir . 'scheduler.lock', 'a+')) )
|
if( ($schedlock = fopen( $lockdir . 'scheduler.lock', 'a+')) )
|
||||||
{
|
{
|
||||||
|
@@ -157,7 +157,7 @@ switch ($parm['action'])
|
|||||||
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'RESETTASKCRASHCOUNTER':
|
case 'RESETTASKCRASHCOUNTER':
|
||||||
$parm = $request->get_parms("task_id");
|
$parm = $request->get_parms("task_id");
|
||||||
try
|
try
|
||||||
@@ -206,79 +206,11 @@ switch ($parm['action'])
|
|||||||
|
|
||||||
$output = $ret->saveXML();
|
$output = $ret->saveXML();
|
||||||
break;
|
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':
|
case 'PINGSCHEDULER_JS':
|
||||||
$ret = array('time'=> date("H:i:s") );
|
$ret = array('time'=> date("H:i:s") );
|
||||||
|
|
||||||
$task_manager = new task_manager($appbox);
|
$task_manager = new task_manager($appbox);
|
||||||
$ret['scheduler'] = $task_manager->get_scheduler_state2();
|
$ret['scheduler'] = $task_manager->get_scheduler_state();
|
||||||
|
|
||||||
$ret['tasks'] = array();
|
$ret['tasks'] = array();
|
||||||
|
|
||||||
@@ -311,7 +243,7 @@ switch ($parm['action'])
|
|||||||
|
|
||||||
$output = p4string::jsonencode($ret);
|
$output = p4string::jsonencode($ret);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'UNMOUNTBASE':
|
case 'UNMOUNTBASE':
|
||||||
$parm = $request->get_parms(array('sbas_id' => http_request::SANITIZE_NUMBER_INT));
|
$parm = $request->get_parms(array('sbas_id' => http_request::SANITIZE_NUMBER_INT));
|
||||||
$ret = array('sbas_id' => null);
|
$ret = array('sbas_id' => null);
|
||||||
|
Reference in New Issue
Block a user