mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-10 03:23:19 +00:00
many comments of last pull request applied
This commit is contained in:
@@ -15,7 +15,6 @@
|
|||||||
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
|
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
|
||||||
* @link www.phraseanet.com
|
* @link www.phraseanet.com
|
||||||
*/
|
*/
|
||||||
|
|
||||||
use Symfony\Component\HttpFoundation\Request;
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
use Silex\Application;
|
use Silex\Application;
|
||||||
|
|
||||||
@@ -177,7 +176,7 @@ class API_V1_adapter extends API_V1_Abstract
|
|||||||
$ret = array('success' => true);
|
$ret = array('success' => true);
|
||||||
try {
|
try {
|
||||||
$task = $taskManager->getTask($taskId);
|
$task = $taskManager->getTask($taskId);
|
||||||
$task->setState(\task_abstract::STATUS_TOSTART);
|
$task->setState(\task_abstract::STATE_TOSTART);
|
||||||
} catch (\Exception_NotFound $e) {
|
} catch (\Exception_NotFound $e) {
|
||||||
$result->set_error_code(404);
|
$result->set_error_code(404);
|
||||||
$ret = array('success' => false);
|
$ret = array('success' => false);
|
||||||
@@ -209,7 +208,7 @@ class API_V1_adapter extends API_V1_Abstract
|
|||||||
$ret = array();
|
$ret = array();
|
||||||
try {
|
try {
|
||||||
$task = $taskManager->getTask($taskId);
|
$task = $taskManager->getTask($taskId);
|
||||||
$task->setState(\task_abstract::STATUS_TOSTOP);
|
$task->setState(\task_abstract::STATE_TOSTOP);
|
||||||
} catch (\Exception_NotFound $e) {
|
} catch (\Exception_NotFound $e) {
|
||||||
$result->set_error_code(404);
|
$result->set_error_code(404);
|
||||||
$ret = array('success' => false);
|
$ret = array('success' => false);
|
||||||
|
@@ -38,7 +38,6 @@ class module_console_schedulerState extends Command
|
|||||||
, 'print short result, ie: <info>stopped</info> | <info>started(12345)</info> | <info>stopping</info>'
|
, 'print short result, ie: <info>stopped</info> | <info>started(12345)</info> | <info>stopping</info>'
|
||||||
, NULL
|
, NULL
|
||||||
);
|
);
|
||||||
// $this->setHelp("");
|
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
@@ -26,7 +26,6 @@ use Symfony\Component\Console\Command\Command;
|
|||||||
class module_console_taskrun extends Command
|
class module_console_taskrun extends Command
|
||||||
{
|
{
|
||||||
private $task;
|
private $task;
|
||||||
|
|
||||||
private $shedulerPID;
|
private $shedulerPID;
|
||||||
|
|
||||||
public function __construct($name = null)
|
public function __construct($name = null)
|
||||||
@@ -125,7 +124,7 @@ class module_console_taskrun extends Command
|
|||||||
if (method_exists($this->task, 'signal'))
|
if (method_exists($this->task, 'signal'))
|
||||||
$this->task->signal('SIGNAL_SCHEDULER_DIED');
|
$this->task->signal('SIGNAL_SCHEDULER_DIED');
|
||||||
else
|
else
|
||||||
$this->task->setState(task_abstract::STATUS_TOSTOP);
|
$this->task->setState(task_abstract::STATE_TOSTOP);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@@ -3,7 +3,7 @@
|
|||||||
/*
|
/*
|
||||||
* This file is part of Phraseanet
|
* This file is part of Phraseanet
|
||||||
*
|
*
|
||||||
* (c) 2005-2010 Alchemy
|
* (c) 2005-2012 Alchemy
|
||||||
*
|
*
|
||||||
* For the full copyright and license information, please view the LICENSE
|
* For the full copyright and license information, please view the LICENSE
|
||||||
* file that was distributed with this source code.
|
* file that was distributed with this source code.
|
||||||
@@ -20,16 +20,12 @@ use Symfony\Component\Console\Output\OutputInterface;
|
|||||||
class task_Scheduler
|
class task_Scheduler
|
||||||
{
|
{
|
||||||
const TASKDELAYTOQUIT = 60;
|
const TASKDELAYTOQUIT = 60;
|
||||||
|
|
||||||
// how to schedule tasks (choose in 'run' method)
|
// how to schedule tasks (choose in 'run' method)
|
||||||
const METHOD_FORK = 'METHOD_FORK';
|
const METHOD_FORK = 'METHOD_FORK';
|
||||||
const METHOD_PROC_OPEN = 'METHOD_PROC_OPEN';
|
const METHOD_PROC_OPEN = 'METHOD_PROC_OPEN';
|
||||||
|
|
||||||
const ERR_ALREADY_RUNNING = 114; // aka EALREADY (Operation already in progress)
|
const ERR_ALREADY_RUNNING = 114; // aka EALREADY (Operation already in progress)
|
||||||
private $method;
|
private $method;
|
||||||
|
|
||||||
private $input;
|
private $input;
|
||||||
|
|
||||||
protected $output;
|
protected $output;
|
||||||
|
|
||||||
protected function log($message)
|
protected function log($message)
|
||||||
@@ -47,6 +43,7 @@ class task_Scheduler
|
|||||||
if ($this->input && ! ($this->input->getOption('nolog'))) {
|
if ($this->input && ! ($this->input->getOption('nolog'))) {
|
||||||
file_put_contents($logdir . "scheduler_l.log", $message . "\n", FILE_APPEND);
|
file_put_contents($logdir . "scheduler_l.log", $message . "\n", FILE_APPEND);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -55,7 +52,7 @@ class task_Scheduler
|
|||||||
return appbox::get_instance(\bootstrap::getCore())->get_connection();
|
return appbox::get_instance(\bootstrap::getCore())->get_connection();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function run($input=null, OutputInterface $output = null) //, $log = true, $log_tasks = true)
|
public function run($input=null, OutputInterface $output = null)
|
||||||
{
|
{
|
||||||
require_once dirname(__FILE__) . '/../../bootstrap.php';
|
require_once dirname(__FILE__) . '/../../bootstrap.php';
|
||||||
$this->input = $input;
|
$this->input = $input;
|
||||||
@@ -134,7 +131,7 @@ class task_Scheduler
|
|||||||
if ( ! $task->getPID()) {
|
if ( ! $task->getPID()) {
|
||||||
/* @var $task task_abstract */
|
/* @var $task task_abstract */
|
||||||
$task->resetCrashCounter();
|
$task->resetCrashCounter();
|
||||||
$task->setState(task_abstract::STATUS_TOSTART);
|
$task->setState(task_abstract::STATE_TOSTART);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -313,7 +310,7 @@ class task_Scheduler
|
|||||||
$this->log(sprintf('Unknow status `%s`', $status));
|
$this->log(sprintf('Unknow status `%s`', $status));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case task_abstract::STATUS_TORESTART:
|
case task_abstract::STATE_TORESTART:
|
||||||
if ( ! $taskPoll[$tkey]['task']->getPID()) {
|
if ( ! $taskPoll[$tkey]['task']->getPID()) {
|
||||||
if ($this->method == self::METHOD_PROC_OPEN) {
|
if ($this->method == self::METHOD_PROC_OPEN) {
|
||||||
@fclose($taskPoll[$tkey]["pipes"][1]);
|
@fclose($taskPoll[$tkey]["pipes"][1]);
|
||||||
@@ -323,7 +320,7 @@ class task_Scheduler
|
|||||||
$taskPoll[$tkey]["process"] = null;
|
$taskPoll[$tkey]["process"] = null;
|
||||||
}
|
}
|
||||||
if ($schedstatus == 'started') {
|
if ($schedstatus == 'started') {
|
||||||
$taskPoll[$tkey]["task"]->setState(task_abstract::STATUS_TOSTART);
|
$taskPoll[$tkey]["task"]->setState(task_abstract::STATE_TOSTART);
|
||||||
}
|
}
|
||||||
// trick to start the task immediatly : DON'T break if ending with 'tostart'
|
// trick to start the task immediatly : DON'T break if ending with 'tostart'
|
||||||
// so it will continue with 'tostart' case !
|
// so it will continue with 'tostart' case !
|
||||||
@@ -331,7 +328,7 @@ class task_Scheduler
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case task_abstract::STATUS_TOSTART:
|
case task_abstract::STATE_TOSTART:
|
||||||
// if scheduler is 'tostop', don't launch a new task !
|
// if scheduler is 'tostop', don't launch a new task !
|
||||||
if ($schedstatus != 'started')
|
if ($schedstatus != 'started')
|
||||||
break;
|
break;
|
||||||
@@ -384,21 +381,17 @@ class task_Scheduler
|
|||||||
);
|
);
|
||||||
|
|
||||||
if ($taskPoll[$tkey]["task"]->getCrashCounter() > 5)
|
if ($taskPoll[$tkey]["task"]->getCrashCounter() > 5)
|
||||||
$taskPoll[$tkey]["task"]->setState(task_abstract::STATUS_STOPPED);
|
$taskPoll[$tkey]["task"]->setState(task_abstract::STATE_STOPPED);
|
||||||
else
|
else
|
||||||
$taskPoll[$tkey]["task"]->setState(task_abstract::STATUS_TOSTART);
|
$taskPoll[$tkey]["task"]->setState(task_abstract::STATE_TOSTART);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
elseif ($this->method == self::METHOD_FORK) {
|
elseif ($this->method == self::METHOD_FORK) {
|
||||||
// printf("forking pid %d\n", getmypid());
|
|
||||||
$pid = pcntl_fork();
|
$pid = pcntl_fork();
|
||||||
if ($pid == -1) {
|
if ($pid == -1) {
|
||||||
die("failed to fork");
|
die("failed to fork");
|
||||||
} elseif ($pid == 0) {
|
} elseif ($pid == 0) {
|
||||||
// child
|
|
||||||
// printf("hello i am child pid=%d\n", getmypid());
|
|
||||||
// printf("%s %s \n", $taskPoll[$tkey]["cmd"], implode(' ', $taskPoll[$tkey]["args"]));
|
|
||||||
umask(0);
|
umask(0);
|
||||||
if (posix_setsid() < 0)
|
if (posix_setsid() < 0)
|
||||||
die("Forked process could not detach from terminal\n");
|
die("Forked process could not detach from terminal\n");
|
||||||
@@ -413,25 +406,18 @@ class task_Scheduler
|
|||||||
$this->log(sprintf("exec('%s %s')", $taskPoll[$tkey]["cmd"], implode(' ', $taskPoll[$tkey]["args"])));
|
$this->log(sprintf("exec('%s %s')", $taskPoll[$tkey]["cmd"], implode(' ', $taskPoll[$tkey]["args"])));
|
||||||
pcntl_exec($taskPoll[$tkey]["cmd"], $taskPoll[$tkey]["args"]);
|
pcntl_exec($taskPoll[$tkey]["cmd"], $taskPoll[$tkey]["args"]);
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
// parent
|
|
||||||
// sleep(2);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case task_abstract::STATUS_STARTED:
|
case task_abstract::STATE_STARTED:
|
||||||
$crashed = false;
|
$crashed = false;
|
||||||
// If no process, the task is probably manually ran
|
// If no process, the task is probably manually ran
|
||||||
|
|
||||||
if ($this->method == self::METHOD_PROC_OPEN) {
|
if ($this->method == self::METHOD_PROC_OPEN) {
|
||||||
// printf("=== %d ===\n", __LINE__);
|
|
||||||
if ($taskPoll[$tkey]["process"]) {
|
if ($taskPoll[$tkey]["process"]) {
|
||||||
// printf("=== %d ===\n", __LINE__);
|
|
||||||
$taskPoll[$tkey]["killat"] = NULL;
|
$taskPoll[$tkey]["killat"] = NULL;
|
||||||
|
|
||||||
if (is_resource($taskPoll[$tkey]["process"])) {
|
if (is_resource($taskPoll[$tkey]["process"])) {
|
||||||
// printf("=== %d ===\n", __LINE__);
|
|
||||||
$proc_status = proc_get_status($taskPoll[$tkey]["process"]);
|
$proc_status = proc_get_status($taskPoll[$tkey]["process"]);
|
||||||
if ($proc_status['running'])
|
if ($proc_status['running'])
|
||||||
$runningtask ++;
|
$runningtask ++;
|
||||||
@@ -439,14 +425,12 @@ class task_Scheduler
|
|||||||
$crashed = true;
|
$crashed = true;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// printf("=== %d ===\n", __LINE__);
|
|
||||||
$crashed = true;
|
$crashed = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( ! $crashed && ! $taskPoll[$tkey]['task']->getPID()) {
|
if ( ! $crashed && ! $taskPoll[$tkey]['task']->getPID()) {
|
||||||
// printf("=== %d ===\n", __LINE__);
|
|
||||||
$crashed = true;
|
$crashed = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -454,7 +438,6 @@ class task_Scheduler
|
|||||||
$taskPoll[$tkey]["killat"] = NULL;
|
$taskPoll[$tkey]["killat"] = NULL;
|
||||||
$runningtask ++;
|
$runningtask ++;
|
||||||
} else {
|
} else {
|
||||||
// printf("=== %d ===\n", __LINE__);
|
|
||||||
// crashed !
|
// crashed !
|
||||||
$taskPoll[$tkey]["task"]->incrementCrashCounter();
|
$taskPoll[$tkey]["task"]->incrementCrashCounter();
|
||||||
|
|
||||||
@@ -473,13 +456,13 @@ class task_Scheduler
|
|||||||
);
|
);
|
||||||
|
|
||||||
if ($taskPoll[$tkey]["task"]->getCrashCounter() > 5)
|
if ($taskPoll[$tkey]["task"]->getCrashCounter() > 5)
|
||||||
$taskPoll[$tkey]["task"]->setState(task_abstract::STATUS_STOPPED);
|
$taskPoll[$tkey]["task"]->setState(task_abstract::STATE_STOPPED);
|
||||||
else
|
else
|
||||||
$taskPoll[$tkey]["task"]->setState(task_abstract::STATUS_TOSTART);
|
$taskPoll[$tkey]["task"]->setState(task_abstract::STATE_TOSTART);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case task_abstract::STATUS_TOSTOP:
|
case task_abstract::STATE_TOSTOP:
|
||||||
|
|
||||||
if ($taskPoll[$tkey]["killat"] === NULL)
|
if ($taskPoll[$tkey]["killat"] === NULL)
|
||||||
$taskPoll[$tkey]["killat"] = time() + self::TASKDELAYTOQUIT;
|
$taskPoll[$tkey]["killat"] = time() + self::TASKDELAYTOQUIT;
|
||||||
@@ -525,13 +508,6 @@ class task_Scheduler
|
|||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
/*
|
|
||||||
unlink($lockdir . 'task_' . $taskPoll[$tkey]['task']->getID() . '.lock');
|
|
||||||
|
|
||||||
$taskPoll[$tkey]["task"]->incrementCrashCounter();
|
|
||||||
// $taskPoll[$tkey]["task"]->set_pid(null);
|
|
||||||
$taskPoll[$tkey]["task"]->setState(task_abstract::STATUS_STOPPED);
|
|
||||||
*/
|
|
||||||
} else {
|
} else {
|
||||||
$this->log(
|
$this->log(
|
||||||
sprintf(
|
sprintf(
|
||||||
@@ -549,13 +525,13 @@ class task_Scheduler
|
|||||||
, $taskPoll[$tkey]["task"]->getID()
|
, $taskPoll[$tkey]["task"]->getID()
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
$taskPoll[$tkey]["task"]->setState(task_abstract::STATUS_STOPPED);
|
$taskPoll[$tkey]["task"]->setState(task_abstract::STATE_STOPPED);
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case task_abstract::STATUS_STOPPED:
|
case task_abstract::STATE_STOPPED:
|
||||||
case task_abstract::STATUS_TODELETE:
|
case task_abstract::STATE_TODELETE:
|
||||||
if ($this->method == self::METHOD_PROC_OPEN) {
|
if ($this->method == self::METHOD_PROC_OPEN) {
|
||||||
if ($taskPoll[$tkey]["process"]) {
|
if ($taskPoll[$tkey]["process"]) {
|
||||||
@fclose($taskPoll[$tkey]["pipes"][1]);
|
@fclose($taskPoll[$tkey]["pipes"][1]);
|
||||||
|
@@ -5,12 +5,12 @@ abstract class task_abstract
|
|||||||
const LAUCHED_BY_BROWSER = 1;
|
const LAUCHED_BY_BROWSER = 1;
|
||||||
const LAUCHED_BY_COMMANDLINE = 2;
|
const LAUCHED_BY_COMMANDLINE = 2;
|
||||||
|
|
||||||
const STATUS_TOSTOP = 'tostop';
|
const STATE_TOSTOP = 'tostop';
|
||||||
const STATUS_STARTED = 'started';
|
const STATE_STARTED = 'started';
|
||||||
const STATUS_TOSTART = 'tostart';
|
const STATE_TOSTART = 'tostart';
|
||||||
const STATUS_TORESTART = 'torestart';
|
const STATE_TORESTART = 'torestart';
|
||||||
const STATUS_STOPPED = 'stopped';
|
const STATE_STOPPED = 'stopped';
|
||||||
const STATUS_TODELETE = 'todelete';
|
const STATE_TODELETE = 'todelete';
|
||||||
|
|
||||||
const RUNNER_MANUAL = 'manual';
|
const RUNNER_MANUAL = 'manual';
|
||||||
const RUNNER_SCHEDULER = 'scheduler';
|
const RUNNER_SCHEDULER = 'scheduler';
|
||||||
@@ -24,7 +24,6 @@ abstract class task_abstract
|
|||||||
|
|
||||||
const ERR_ALREADY_RUNNING = 114; // aka EALREADY (Operation already in progress)
|
const ERR_ALREADY_RUNNING = 114; // aka EALREADY (Operation already in progress)
|
||||||
protected $suicidable = false;
|
protected $suicidable = false;
|
||||||
|
|
||||||
protected $launched_by = 0;
|
protected $launched_by = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -75,11 +74,8 @@ abstract class task_abstract
|
|||||||
* @var <type>
|
* @var <type>
|
||||||
*/
|
*/
|
||||||
protected $maxmegs;
|
protected $maxmegs;
|
||||||
|
|
||||||
protected $runner;
|
protected $runner;
|
||||||
|
|
||||||
private $input;
|
private $input;
|
||||||
|
|
||||||
private $output;
|
private $output;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -88,25 +84,15 @@ abstract class task_abstract
|
|||||||
* @var <type>
|
* @var <type>
|
||||||
*/
|
*/
|
||||||
protected $title;
|
protected $title;
|
||||||
|
|
||||||
protected $settings;
|
protected $settings;
|
||||||
|
|
||||||
protected $crash_counter;
|
protected $crash_counter;
|
||||||
|
|
||||||
protected $status;
|
protected $status;
|
||||||
|
|
||||||
protected $active;
|
protected $active;
|
||||||
|
|
||||||
protected $debug = false;
|
protected $debug = false;
|
||||||
|
|
||||||
protected $completed_percentage;
|
protected $completed_percentage;
|
||||||
|
|
||||||
protected $period = 60;
|
protected $period = 60;
|
||||||
|
|
||||||
protected $taskid = NULL;
|
protected $taskid = NULL;
|
||||||
|
|
||||||
protected $system = ''; // "DARWIN", "WINDOWS" , "LINUX"...
|
protected $system = ''; // "DARWIN", "WINDOWS" , "LINUX"...
|
||||||
|
|
||||||
protected $argt = array(
|
protected $argt = array(
|
||||||
"--help" => array("set" => false, "values" => array(), "usage" => " (no help available)")
|
"--help" => array("set" => false, "values" => array(), "usage" => " (no help available)")
|
||||||
);
|
);
|
||||||
@@ -114,13 +100,14 @@ abstract class task_abstract
|
|||||||
public function getState()
|
public function getState()
|
||||||
{
|
{
|
||||||
$conn = connection::getPDOConnection();
|
$conn = connection::getPDOConnection();
|
||||||
$sql = 'SELECT status FROM task2 WHERE task_id = :taskid LIMIT 1';
|
$sql = 'SELECT status FROM task2 WHERE task_id = :taskid';
|
||||||
$stmt = $conn->prepare($sql);
|
$stmt = $conn->prepare($sql);
|
||||||
$stmt->execute(array(':taskid' => $this->taskid));
|
$stmt->execute(array(':taskid' => $this->taskid));
|
||||||
$row = $stmt->fetch(PDO::FETCH_ASSOC);
|
$row = $stmt->fetch(PDO::FETCH_ASSOC);
|
||||||
$stmt->closeCursor();
|
$stmt->closeCursor();
|
||||||
if ( ! $row)
|
if ( ! $row)
|
||||||
throw new Exception('Unknown task id');
|
throw new Exception('Unknown task id');
|
||||||
|
|
||||||
return $row['status'];
|
return $row['status'];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -142,12 +129,12 @@ abstract class task_abstract
|
|||||||
public function setState($status)
|
public function setState($status)
|
||||||
{
|
{
|
||||||
$av_status = array(
|
$av_status = array(
|
||||||
self::STATUS_STARTED
|
self::STATE_STARTED
|
||||||
, self::STATUS_TOSTOP
|
, self::STATE_TOSTOP
|
||||||
, self::STATUS_STOPPED
|
, self::STATE_STOPPED
|
||||||
, self::STATUS_TORESTART
|
, self::STATE_TORESTART
|
||||||
, self::STATUS_TOSTART
|
, self::STATE_TOSTART
|
||||||
, self::STATUS_TODELETE
|
, self::STATE_TODELETE
|
||||||
);
|
);
|
||||||
|
|
||||||
if ( ! in_array($status, $av_status)) {
|
if ( ! in_array($status, $av_status)) {
|
||||||
@@ -293,7 +280,7 @@ abstract class task_abstract
|
|||||||
return('');
|
return('');
|
||||||
}
|
}
|
||||||
$sql = 'SELECT crashed, pid, status, active, settings, name, completed, runner
|
$sql = 'SELECT crashed, pid, status, active, settings, name, completed, runner
|
||||||
FROM task2 WHERE task_id = :taskid LIMIT 1';
|
FROM task2 WHERE task_id = :taskid';
|
||||||
$stmt = $conn->prepare($sql);
|
$stmt = $conn->prepare($sql);
|
||||||
$stmt->execute(array(':taskid' => $this->getID()));
|
$stmt->execute(array(':taskid' => $this->getID()));
|
||||||
$row = $stmt->fetch(PDO::FETCH_ASSOC);
|
$row = $stmt->fetch(PDO::FETCH_ASSOC);
|
||||||
@@ -394,6 +381,7 @@ abstract class task_abstract
|
|||||||
}
|
}
|
||||||
fclose($fd);
|
fclose($fd);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $pid;
|
return $pid;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -408,13 +396,10 @@ abstract class task_abstract
|
|||||||
if ($this->running) {// && $this->records_done == 0)
|
if ($this->running) {// && $this->records_done == 0)
|
||||||
$when_started = time() - $when_started;
|
$when_started = time() - $when_started;
|
||||||
if ($when_started < $this->period) {
|
if ($when_started < $this->period) {
|
||||||
// $conn = connection::getPDOConnection();
|
|
||||||
// $conn->close();
|
|
||||||
// unset($conn);
|
|
||||||
for ($t = $this->period - $when_started; $this->running && $t > 0; $t -- ) { // DON'T do sleep($this->period - $when_started) because it prevents ticks !
|
for ($t = $this->period - $when_started; $this->running && $t > 0; $t -- ) { // DON'T do sleep($this->period - $when_started) because it prevents ticks !
|
||||||
$s = $this->getState();
|
$s = $this->getState();
|
||||||
if ($s == self::STATUS_TOSTOP) {
|
if ($s == self::STATE_TOSTOP) {
|
||||||
$this->setState(self::STATUS_STOPPED);
|
$this->setState(self::STATE_STOPPED);
|
||||||
$this->running = FALSE;
|
$this->running = FALSE;
|
||||||
} else {
|
} else {
|
||||||
sleep(1);
|
sleep(1);
|
||||||
@@ -456,7 +441,7 @@ abstract class task_abstract
|
|||||||
flock($tasklock, LOCK_SH);
|
flock($tasklock, LOCK_SH);
|
||||||
|
|
||||||
$this->setRunner($runner);
|
$this->setRunner($runner);
|
||||||
$this->setState(self::STATUS_STARTED);
|
$this->setState(self::STATE_STARTED);
|
||||||
|
|
||||||
// run the real code of the task -into the task's class- (may throw an exception)
|
// run the real code of the task -into the task's class- (may throw an exception)
|
||||||
$exception = NULL;
|
$exception = NULL;
|
||||||
@@ -473,11 +458,11 @@ abstract class task_abstract
|
|||||||
@unlink($lockfile);
|
@unlink($lockfile);
|
||||||
|
|
||||||
switch ($this->getState()) {
|
switch ($this->getState()) {
|
||||||
case self::STATUS_TODELETE:
|
case self::STATE_TODELETE:
|
||||||
$this->delete();
|
$this->delete();
|
||||||
break;
|
break;
|
||||||
case self::STATUS_TOSTOP:
|
case self::STATE_TOSTOP:
|
||||||
$this->setState(self::STATUS_STOPPED);
|
$this->setState(self::STATE_STOPPED);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -509,8 +494,7 @@ abstract class task_abstract
|
|||||||
{
|
{
|
||||||
if ($this->getRunner() == self::RUNNER_SCHEDULER && ++ $this->loop >= $this->maxloops) {
|
if ($this->getRunner() == self::RUNNER_SCHEDULER && ++ $this->loop >= $this->maxloops) {
|
||||||
$this->log(sprintf(('%d loops done, restarting'), $this->loop));
|
$this->log(sprintf(('%d loops done, restarting'), $this->loop));
|
||||||
$this->setState(self::STATUS_TORESTART);
|
$this->setState(self::STATE_TORESTART);
|
||||||
// $this->return_xxxvalue = self::RETURNSTATUS_TORESTART;
|
|
||||||
|
|
||||||
$this->running = false;
|
$this->running = false;
|
||||||
}
|
}
|
||||||
@@ -529,7 +513,6 @@ abstract class task_abstract
|
|||||||
|
|
||||||
$lastt = $t;
|
$lastt = $t;
|
||||||
echo "\n" . memory_get_usage() . " -- " . memory_get_usage(true) . "\n";
|
echo "\n" . memory_get_usage() . " -- " . memory_get_usage(true) . "\n";
|
||||||
// print($s);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function log($message)
|
public function log($message)
|
||||||
@@ -609,7 +592,6 @@ abstract class task_abstract
|
|||||||
return($t);
|
return($t);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public function getID()
|
public function getID()
|
||||||
{
|
{
|
||||||
return $this->taskid;
|
return $this->taskid;
|
||||||
|
@@ -34,8 +34,10 @@ abstract class task_appboxAbstract extends task_abstract
|
|||||||
if ($this->getRunner() == self::RUNNER_SCHEDULER) {
|
if ($this->getRunner() == self::RUNNER_SCHEDULER) {
|
||||||
$this->log(("Warning : abox connection lost, restarting in 10 min."));
|
$this->log(("Warning : abox connection lost, restarting in 10 min."));
|
||||||
|
|
||||||
for ($t = 60 * 10; $this->running && $t; $t -- ) // DON'T do sleep(600) because it prevents ticks !
|
// DON'T do sleep(600) because it prevents ticks !
|
||||||
|
for ($t = 60 * 10; $this->running && $t; $t -- ) {
|
||||||
sleep(1);
|
sleep(1);
|
||||||
|
}
|
||||||
// because connection is lost we cannot change status to 'torestart'
|
// because connection is lost we cannot change status to 'torestart'
|
||||||
// anyway the current status 'running' with no pid
|
// anyway the current status 'running' with no pid
|
||||||
// will enforce the scheduler to restart the task
|
// will enforce the scheduler to restart the task
|
||||||
@@ -50,7 +52,7 @@ abstract class task_appboxAbstract extends task_abstract
|
|||||||
$this->setLastExecTime();
|
$this->setLastExecTime();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$sql = 'SELECT task2.* FROM task2 WHERE task_id = :taskid LIMIT 1';
|
$sql = 'SELECT settings FROM task2 WHERE task_id = :taskid';
|
||||||
$stmt = $conn->prepare($sql);
|
$stmt = $conn->prepare($sql);
|
||||||
$stmt->execute(array(':taskid' => $this->getID()));
|
$stmt->execute(array(':taskid' => $this->getID()));
|
||||||
$row = $stmt->fetch(PDO::FETCH_ASSOC);
|
$row = $stmt->fetch(PDO::FETCH_ASSOC);
|
||||||
@@ -82,18 +84,18 @@ abstract class task_appboxAbstract extends task_abstract
|
|||||||
case self::STATE_MAXMEGSREACHED:
|
case self::STATE_MAXMEGSREACHED:
|
||||||
case self::STATE_MAXRECSDONE:
|
case self::STATE_MAXRECSDONE:
|
||||||
if ($this->getRunner() == self::RUNNER_SCHEDULER) {
|
if ($this->getRunner() == self::RUNNER_SCHEDULER) {
|
||||||
$this->setState(self::STATUS_TORESTART);
|
$this->setState(self::STATE_TORESTART);
|
||||||
$this->running = FALSE;
|
$this->running = FALSE;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case self::STATUS_TOSTOP:
|
case self::STATE_TOSTOP:
|
||||||
$this->setState(self::STATUS_TOSTOP);
|
$this->setState(self::STATE_TOSTOP);
|
||||||
$this->running = FALSE;
|
$this->running = FALSE;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case self::STATUS_TODELETE: // formal 'suicidable'
|
case self::STATE_TODELETE: // formal 'suicidable'
|
||||||
$this->setState(self::STATUS_TODELETE);
|
$this->setState(self::STATE_TODELETE);
|
||||||
$this->running = FALSE;
|
$this->running = FALSE;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@@ -164,9 +166,9 @@ abstract class task_appboxAbstract extends task_abstract
|
|||||||
// $this->check_task_status();
|
// $this->check_task_status();
|
||||||
try {
|
try {
|
||||||
$status = $this->getState();
|
$status = $this->getState();
|
||||||
if ($status == self::STATUS_TOSTOP) {
|
if ($status == self::STATE_TOSTOP) {
|
||||||
$this->running = FALSE;
|
$this->running = FALSE;
|
||||||
$ret = self::STATUS_TOSTOP;
|
$ret = self::STATE_TOSTOP;
|
||||||
}
|
}
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
$this->running = FALSE;
|
$this->running = FALSE;
|
||||||
@@ -174,11 +176,11 @@ abstract class task_appboxAbstract extends task_abstract
|
|||||||
|
|
||||||
if ( ! $this->running)
|
if ( ! $this->running)
|
||||||
break;
|
break;
|
||||||
} // foreach($rs as $row)
|
}
|
||||||
//
|
//
|
||||||
// if nothing was done, at least check the status
|
// if nothing was done, at least check the status
|
||||||
if (count($rs) == 0 && $this->running) {
|
if (count($rs) == 0 && $this->running) {
|
||||||
// $this->check_memory_usage();
|
|
||||||
$current_memory = memory_get_usage();
|
$current_memory = memory_get_usage();
|
||||||
if ($current_memory >> 20 >= $this->maxmegs) {
|
if ($current_memory >> 20 >= $this->maxmegs) {
|
||||||
$this->log(sprintf("Max memory (%s M) reached (current is %s M)", $this->maxmegs, $current_memory));
|
$this->log(sprintf("Max memory (%s M) reached (current is %s M)", $this->maxmegs, $current_memory));
|
||||||
@@ -192,12 +194,11 @@ abstract class task_appboxAbstract extends task_abstract
|
|||||||
$ret = self::STATE_MAXRECSDONE;
|
$ret = self::STATE_MAXRECSDONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
// $this->check_task_status();
|
|
||||||
try {
|
try {
|
||||||
$status = $this->getState();
|
$status = $this->getState();
|
||||||
if ($status == self::STATUS_TOSTOP) {
|
if ($status == self::STATE_TOSTOP) {
|
||||||
$this->running = FALSE;
|
$this->running = FALSE;
|
||||||
$ret = self::STATUS_TOSTOP;
|
$ret = self::STATE_TOSTOP;
|
||||||
}
|
}
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
$this->running = FALSE;
|
$this->running = FALSE;
|
||||||
|
@@ -37,13 +37,15 @@ abstract class task_databoxAbstract extends task_abstract
|
|||||||
while ($this->running) {
|
while ($this->running) {
|
||||||
try {
|
try {
|
||||||
$conn = connection::getPDOConnection();
|
$conn = connection::getPDOConnection();
|
||||||
} catch (Exception $e) {
|
} catch (PDOException $e) {
|
||||||
$this->log($e->getMessage());
|
$this->log($e->getMessage());
|
||||||
if ($this->getRunner() == self::RUNNER_SCHEDULER) {
|
if ($this->getRunner() == self::RUNNER_SCHEDULER) {
|
||||||
$this->log(("Warning : abox connection lost, restarting in 10 min."));
|
$this->log(("Warning : abox connection lost, restarting in 10 min."));
|
||||||
|
|
||||||
for ($t = 60 * 10; $this->running && $t; $t -- ) // DON'T do sleep(600) because it prevents ticks !
|
// DON'T do sleep(600) because it prevents ticks !
|
||||||
|
for ($t = 60 * 10; $this->running && $t; $t -- ) {
|
||||||
sleep(1);
|
sleep(1);
|
||||||
|
}
|
||||||
// because connection is lost we cannot change status to 'torestart'
|
// because connection is lost we cannot change status to 'torestart'
|
||||||
// anyway the current status 'running' with no pid
|
// anyway the current status 'running' with no pid
|
||||||
// will enforce the scheduler to restart the task
|
// will enforce the scheduler to restart the task
|
||||||
@@ -51,6 +53,7 @@ abstract class task_databoxAbstract extends task_abstract
|
|||||||
// runner = manual : can't restart so simply quit
|
// runner = manual : can't restart so simply quit
|
||||||
}
|
}
|
||||||
$this->running = FALSE;
|
$this->running = FALSE;
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -91,27 +94,22 @@ abstract class task_databoxAbstract extends task_abstract
|
|||||||
|
|
||||||
$process_ret = $this->processSbas();
|
$process_ret = $this->processSbas();
|
||||||
|
|
||||||
// printf("%s (%d) process_ret=%s \n", __FILE__, __LINE__, var_export($process_ret, true));
|
|
||||||
// $this->check_current_xxxstate();
|
|
||||||
switch ($process_ret) {
|
switch ($process_ret) {
|
||||||
case self::STATE_MAXMEGSREACHED:
|
case self::STATE_MAXMEGSREACHED:
|
||||||
case self::STATE_MAXRECSDONE:
|
case self::STATE_MAXRECSDONE:
|
||||||
if ($this->getRunner() == self::RUNNER_SCHEDULER) {
|
if ($this->getRunner() == self::RUNNER_SCHEDULER) {
|
||||||
$this->setState(self::STATUS_TORESTART);
|
$this->setState(self::STATE_TORESTART);
|
||||||
$this->running = FALSE;
|
$this->running = FALSE;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case self::STATUS_TOSTOP:
|
case self::STATE_TOSTOP:
|
||||||
$this->setState(self::STATUS_TOSTOP);
|
$this->setState(self::STATE_TOSTOP);
|
||||||
$this->running = FALSE;
|
$this->running = FALSE;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case self::STATUS_TODELETE: // formal 'suicidable'
|
case self::STATE_TODELETE: // formal 'suicidable'
|
||||||
// DO NOT SUICIDE IN THE LOOP, may have to work on other sbas !!!
|
// DO NOT SUICIDE IN THE LOOP, may have to work on other sbas !!!
|
||||||
// $this->setState(self::STATUS_TODELETE);
|
|
||||||
// $this->log('task will self delete');
|
|
||||||
// $this->running = FALSE;
|
|
||||||
$task_must_delete = TRUE;
|
$task_must_delete = TRUE;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@@ -120,16 +118,17 @@ abstract class task_databoxAbstract extends task_abstract
|
|||||||
}
|
}
|
||||||
|
|
||||||
$this->flushRecordsSbas();
|
$this->flushRecordsSbas();
|
||||||
} // foreach sbas
|
}
|
||||||
|
|
||||||
$this->incrementLoops();
|
$this->incrementLoops();
|
||||||
$this->pause($duration);
|
$this->pause($duration);
|
||||||
} // while($this->running)
|
}
|
||||||
|
|
||||||
if ($task_must_delete) {
|
if ($task_must_delete) {
|
||||||
$this->setState(self::STATUS_TODELETE);
|
$this->setState(self::STATE_TODELETE);
|
||||||
$this->log('task will self delete');
|
$this->log('task will self delete');
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -174,7 +173,6 @@ abstract class task_databoxAbstract extends task_abstract
|
|||||||
// post-process
|
// post-process
|
||||||
$this->postProcessOneContent($databox, $row);
|
$this->postProcessOneContent($databox, $row);
|
||||||
|
|
||||||
// $this->check_memory_usage();
|
|
||||||
$current_memory = memory_get_usage();
|
$current_memory = memory_get_usage();
|
||||||
if ($current_memory >> 20 >= $this->maxmegs) {
|
if ($current_memory >> 20 >= $this->maxmegs) {
|
||||||
$this->log(sprintf("Max memory (%s M) reached (actual is %s M)", $this->maxmegs, $current_memory));
|
$this->log(sprintf("Max memory (%s M) reached (actual is %s M)", $this->maxmegs, $current_memory));
|
||||||
@@ -188,29 +186,23 @@ abstract class task_databoxAbstract extends task_abstract
|
|||||||
$ret = self::STATE_MAXRECSDONE;
|
$ret = self::STATE_MAXRECSDONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
// $this->check_task_status();
|
|
||||||
try {
|
try {
|
||||||
$status = $this->getState();
|
$status = $this->getState();
|
||||||
// printf("%s (%d) status=%s \n", __FILE__, __LINE__, var_export($status, true));
|
if ($status == self::STATE_TOSTOP) {
|
||||||
if ($status == self::STATUS_TOSTOP) {
|
|
||||||
$this->running = FALSE;
|
$this->running = FALSE;
|
||||||
$ret = self::STATUS_TOSTOP;
|
$ret = self::STATE_TOSTOP;
|
||||||
}
|
}
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
$this->running = FALSE;
|
$this->running = FALSE;
|
||||||
// $this->task_status = self::STATUS_TOSTOP;
|
|
||||||
// $this->return_xxxvalue = self::RETURNSTATUS_STOPPED;
|
|
||||||
}
|
}
|
||||||
// if($this->task_status == self::STATUS_TOSTOP)
|
|
||||||
// $this->running = false;
|
|
||||||
|
|
||||||
|
|
||||||
if ( ! $this->running)
|
if ( ! $this->running)
|
||||||
break;
|
break;
|
||||||
} // foreach($rs as $row)
|
}
|
||||||
|
//
|
||||||
// if nothing was done, at least check the status
|
// if nothing was done, at least check the status
|
||||||
if (count($rs) == 0 && $this->running) {
|
if (count($rs) == 0 && $this->running) {
|
||||||
// $this->check_memory_usage();
|
|
||||||
$current_memory = memory_get_usage();
|
$current_memory = memory_get_usage();
|
||||||
if ($current_memory >> 20 >= $this->maxmegs) {
|
if ($current_memory >> 20 >= $this->maxmegs) {
|
||||||
$this->log(sprintf("Max memory (%s M) reached (current is %s M)", $this->maxmegs, $current_memory));
|
$this->log(sprintf("Max memory (%s M) reached (current is %s M)", $this->maxmegs, $current_memory));
|
||||||
@@ -224,20 +216,14 @@ abstract class task_databoxAbstract extends task_abstract
|
|||||||
$ret = self::STATE_MAXRECSDONE;
|
$ret = self::STATE_MAXRECSDONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
// $this->check_task_status();
|
|
||||||
try {
|
try {
|
||||||
$status = $this->getState();
|
$status = $this->getState();
|
||||||
// printf("%s (%d) status=%s \n", __FILE__, __LINE__, var_export($status, true));
|
if ($status == self::STATE_TOSTOP) {
|
||||||
if ($status == self::STATUS_TOSTOP) {
|
|
||||||
$this->running = FALSE;
|
$this->running = FALSE;
|
||||||
$ret = self::STATUS_TOSTOP;
|
$ret = self::STATE_TOSTOP;
|
||||||
// $this->task_status = self::STATUS_TOSTOP;
|
|
||||||
// $this->return_xxxvalue = self::RETURNSTATUS_STOPPED;
|
|
||||||
}
|
}
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
$this->running = FALSE;
|
$this->running = FALSE;
|
||||||
// $this->task_status = self::STATUS_TOSTOP;
|
|
||||||
// $this->return_xxxvalue = self::RETURNSTATUS_STOPPED;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -250,7 +236,7 @@ abstract class task_databoxAbstract extends task_abstract
|
|||||||
if ($rowstodo > 0)
|
if ($rowstodo > 0)
|
||||||
$this->setProgress(0, 0);
|
$this->setProgress(0, 0);
|
||||||
|
|
||||||
return($ret);
|
return $ret;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -22,7 +22,6 @@ class task_manager
|
|||||||
const STATUS_SCHED_TOSTOP = 'tostop';
|
const STATUS_SCHED_TOSTOP = 'tostop';
|
||||||
|
|
||||||
protected $appbox;
|
protected $appbox;
|
||||||
|
|
||||||
protected $tasks;
|
protected $tasks;
|
||||||
|
|
||||||
public function __construct(appbox &$appbox)
|
public function __construct(appbox &$appbox)
|
||||||
|
@@ -2,7 +2,7 @@
|
|||||||
/*
|
/*
|
||||||
* This file is part of Phraseanet
|
* This file is part of Phraseanet
|
||||||
*
|
*
|
||||||
* (c) 2005-2010 Alchemy
|
* (c) 2005-2012 Alchemy
|
||||||
*
|
*
|
||||||
* For the full copyright and license information, please view the LICENSE
|
* For the full copyright and license information, please view the LICENSE
|
||||||
* file that was distributed with this source code.
|
* file that was distributed with this source code.
|
||||||
@@ -10,7 +10,6 @@
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @package task_manager
|
|
||||||
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
|
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
|
||||||
* @link www.phraseanet.com
|
* @link www.phraseanet.com
|
||||||
*/
|
*/
|
||||||
@@ -102,7 +101,7 @@ class task_period_archive extends task_abstract
|
|||||||
$ptype = substr($pname, 0, 3);
|
$ptype = substr($pname, 0, 3);
|
||||||
$pname = substr($pname, 4);
|
$pname = substr($pname, 4);
|
||||||
$pvalue = $parm2[$pname];
|
$pvalue = $parm2[$pname];
|
||||||
if ($ns = $dom->getElementsByTagName($pname)->item(0)) {
|
if (($ns = $dom->getElementsByTagName($pname)->item(0))) {
|
||||||
// le champ existait dans le xml, on supprime son ancienne valeur (tout le contenu)
|
// le champ existait dans le xml, on supprime son ancienne valeur (tout le contenu)
|
||||||
while (($n = $ns->firstChild))
|
while (($n = $ns->firstChild))
|
||||||
$ns->removeChild($n);
|
$ns->removeChild($n);
|
||||||
@@ -386,11 +385,11 @@ class task_period_archive extends task_abstract
|
|||||||
|
|
||||||
for ($t = 60 * 10; $this->running && $t; $t -- ) // DON'T do sleep(600) because it prevents ticks !
|
for ($t = 60 * 10; $this->running && $t; $t -- ) // DON'T do sleep(600) because it prevents ticks !
|
||||||
sleep(1);
|
sleep(1);
|
||||||
$this->setState(self::STATUS_TORESTART);
|
$this->setState(self::STATE_TORESTART);
|
||||||
} else {
|
} else {
|
||||||
$this->log(sprintf(('Error : missing hotfolder \'%s\', stopping.'), $path_in));
|
$this->log(sprintf(('Error : missing hotfolder \'%s\', stopping.'), $path_in));
|
||||||
// runner = manual : can't restart so simply quit
|
// runner = manual : can't restart so simply quit
|
||||||
$this->setState(self::STATUS_STOPPED);
|
$this->setState(self::STATE_STOPPED);
|
||||||
}
|
}
|
||||||
$this->running = FALSE;
|
$this->running = FALSE;
|
||||||
return;
|
return;
|
||||||
@@ -426,17 +425,17 @@ class task_period_archive extends task_abstract
|
|||||||
|
|
||||||
for ($t = 60 * 10; $this->running && $t; $t -- ) // DON'T do sleep(600) because it prevents ticks !
|
for ($t = 60 * 10; $this->running && $t; $t -- ) // DON'T do sleep(600) because it prevents ticks !
|
||||||
sleep(1);
|
sleep(1);
|
||||||
$this->setState(self::STATUS_TORESTART);
|
$this->setState(self::STATE_TORESTART);
|
||||||
} else {
|
} else {
|
||||||
$this->log(sprintf(('Error : error fetching task \'%d\', stopping.'), $this->getID()));
|
$this->log(sprintf(('Error : error fetching task \'%d\', stopping.'), $this->getID()));
|
||||||
// runner = manual : can't restart so simply quit
|
// runner = manual : can't restart so simply quit
|
||||||
$this->setState(self::STATUS_STOPPED);
|
$this->setState(self::STATE_STOPPED);
|
||||||
}
|
}
|
||||||
$this->running = FALSE;
|
$this->running = FALSE;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($row['status'] == self::STATUS_TOSTOP) {
|
if ($row['status'] == self::STATE_TOSTOP) {
|
||||||
$this->running = FALSE;
|
$this->running = FALSE;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -449,39 +448,27 @@ class task_period_archive extends task_abstract
|
|||||||
|
|
||||||
switch ($r) {
|
switch ($r) {
|
||||||
case 'TOSTOP':
|
case 'TOSTOP':
|
||||||
$this->setState(self::STATUS_STOPPED);
|
$this->setState(self::STATE_STOPPED);
|
||||||
$this->running = FALSE;
|
$this->running = FALSE;
|
||||||
break;
|
break;
|
||||||
case 'WAIT':
|
case 'WAIT':
|
||||||
$this->setState(self::STATUS_STOPPED);
|
$this->setState(self::STATE_STOPPED);
|
||||||
$this->running = FALSE;
|
$this->running = FALSE;
|
||||||
break;
|
break;
|
||||||
case 'BAD':
|
case 'BAD':
|
||||||
$this->setState(self::STATUS_STOPPED);
|
$this->setState(self::STATE_STOPPED);
|
||||||
$this->running = FALSE;
|
$this->running = FALSE;
|
||||||
break;
|
break;
|
||||||
case 'NORECSTODO':
|
case 'NORECSTODO':
|
||||||
$duration = time() - $duration;
|
$duration = time() - $duration;
|
||||||
if ($duration < ($period + $cold)) {
|
if ($duration < ($period + $cold)) {
|
||||||
/*
|
|
||||||
printf("will close a conn in 5sec...\n");
|
|
||||||
sleep(5);
|
|
||||||
$conn->close();
|
|
||||||
unset($conn);
|
|
||||||
printf("conn closed, waiting 5sec\n");
|
|
||||||
sleep(5);
|
|
||||||
*/
|
|
||||||
for ($i = 0; $i < (($period + $cold) - $duration) && $this->running; $i ++ ) {
|
for ($i = 0; $i < (($period + $cold) - $duration) && $this->running; $i ++ ) {
|
||||||
$s = $this->getState();
|
$s = $this->getState();
|
||||||
if ($s == self::STATUS_TOSTOP) {
|
if ($s == self::STATE_TOSTOP) {
|
||||||
$this->setState(self::STATUS_STOPPED);
|
$this->setState(self::STATE_STOPPED);
|
||||||
$this->running = FALSE;
|
$this->running = FALSE;
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
// $conn->close();
|
|
||||||
// unset($conn);
|
|
||||||
sleep(1);
|
sleep(1);
|
||||||
// $conn = connection::getPDOConnection();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -489,14 +476,14 @@ class task_period_archive extends task_abstract
|
|||||||
case 'MAXRECSDONE':
|
case 'MAXRECSDONE':
|
||||||
case 'MAXMEMORY':
|
case 'MAXMEMORY':
|
||||||
case 'MAXLOOP':
|
case 'MAXLOOP':
|
||||||
if ($row['status'] == self::STATUS_STARTED && $this->getRunner() !== self::RUNNER_MANUAL) {
|
if ($row['status'] == self::STATE_STARTED && $this->getRunner() !== self::RUNNER_MANUAL) {
|
||||||
$this->setState(self::STATUS_TORESTART);
|
$this->setState(self::STATE_TORESTART);
|
||||||
$this->running = FALSE;
|
$this->running = FALSE;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
if ($row['status'] == self::STATUS_STARTED) {
|
if ($row['status'] == self::STATE_STARTED) {
|
||||||
$this->setState(self::STATUS_STOPPED);
|
$this->setState(self::STATE_STOPPED);
|
||||||
$this->running = FALSE;
|
$this->running = FALSE;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -513,8 +500,6 @@ class task_period_archive extends task_abstract
|
|||||||
*/
|
*/
|
||||||
function archiveHotFolder($server_coll_id)
|
function archiveHotFolder($server_coll_id)
|
||||||
{
|
{
|
||||||
// $this->filesToIgnore = array('.', '..', 'Thumbs.db', '');
|
|
||||||
|
|
||||||
clearstatcache();
|
clearstatcache();
|
||||||
|
|
||||||
$conn = connection::getPDOConnection();
|
$conn = connection::getPDOConnection();
|
||||||
@@ -570,7 +555,7 @@ class task_period_archive extends task_abstract
|
|||||||
|
|
||||||
while ($cold > 0) {
|
while ($cold > 0) {
|
||||||
$s = $this->getState();
|
$s = $this->getState();
|
||||||
if ($s == self::STATUS_TOSTOP)
|
if ($s == self::STATE_TOSTOP)
|
||||||
return('TOSTOP');
|
return('TOSTOP');
|
||||||
sleep(2);
|
sleep(2);
|
||||||
$cold -= 2;
|
$cold -= 2;
|
||||||
@@ -724,7 +709,7 @@ class task_period_archive extends task_abstract
|
|||||||
while (($file = $listFolder->read()) !== NULL) {
|
while (($file = $listFolder->read()) !== NULL) {
|
||||||
if (time() - $time0 >= 2) { // each 2 secs, check the status of the task
|
if (time() - $time0 >= 2) { // each 2 secs, check the status of the task
|
||||||
$s = $this->getState();
|
$s = $this->getState();
|
||||||
if ($s == self::STATUS_TOSTOP) {
|
if ($s == self::STATE_TOSTOP) {
|
||||||
$nnew = 'TOSTOP'; // since we will return a string...
|
$nnew = 'TOSTOP'; // since we will return a string...
|
||||||
break; // ...we can check it against numerical result
|
break; // ...we can check it against numerical result
|
||||||
}
|
}
|
||||||
@@ -779,7 +764,7 @@ class task_period_archive extends task_abstract
|
|||||||
* @param <type> $depth
|
* @param <type> $depth
|
||||||
* @return <type>
|
* @return <type>
|
||||||
*/
|
*/
|
||||||
function listFilesPhase2($dom, $node, $path, $depth=0)
|
function listFilesPhase2($dom, $node, $path, $depth = 0)
|
||||||
{
|
{
|
||||||
static $iloop = 0;
|
static $iloop = 0;
|
||||||
if ($depth == 0)
|
if ($depth == 0)
|
||||||
@@ -877,7 +862,7 @@ class task_period_archive extends task_abstract
|
|||||||
* @param <type> $depth
|
* @param <type> $depth
|
||||||
* @return <type>
|
* @return <type>
|
||||||
*/
|
*/
|
||||||
function makePairs($dom, $node, $path, $path_archived, $path_error, $inGrp=false, $depth=0)
|
function makePairs($dom, $node, $path, $path_archived, $path_error, $inGrp = false, $depth = 0)
|
||||||
{
|
{
|
||||||
static $iloop = 0;
|
static $iloop = 0;
|
||||||
if ($depth == 0)
|
if ($depth == 0)
|
||||||
@@ -903,7 +888,6 @@ class task_period_archive extends task_abstract
|
|||||||
if ($n->getAttribute('isdir') == '1') {
|
if ($n->getAttribute('isdir') == '1') {
|
||||||
if (($grpSettings = $this->getGrpSettings($name)) !== FALSE) { // get 'caption', 'representation'
|
if (($grpSettings = $this->getGrpSettings($name)) !== FALSE) { // get 'caption', 'representation'
|
||||||
// this is a grp folder, we check it
|
// this is a grp folder, we check it
|
||||||
|
|
||||||
$dnl = $xpath->query('./file[@name=".grouping.xml"]', $n);
|
$dnl = $xpath->query('./file[@name=".grouping.xml"]', $n);
|
||||||
if ($dnl->length == 1) {
|
if ($dnl->length == 1) {
|
||||||
// this group is old (don't care about any linked files), just flag it
|
// this group is old (don't care about any linked files), just flag it
|
||||||
@@ -1010,7 +994,7 @@ class task_period_archive extends task_abstract
|
|||||||
* @param <type> $depth
|
* @param <type> $depth
|
||||||
* @return <type>
|
* @return <type>
|
||||||
*/
|
*/
|
||||||
function removeBadGroups($dom, $node, $path, $path_archived, $path_error, $depth=0)
|
function removeBadGroups($dom, $node, $path, $path_archived, $path_error, $depth = 0)
|
||||||
{
|
{
|
||||||
static $iloop = 0;
|
static $iloop = 0;
|
||||||
if ($depth == 0)
|
if ($depth == 0)
|
||||||
@@ -1033,11 +1017,6 @@ class task_period_archive extends task_abstract
|
|||||||
|
|
||||||
if ($n->getAttribute('isdir')) {
|
if ($n->getAttribute('isdir')) {
|
||||||
// a dir
|
// a dir
|
||||||
// if($n->getAttribute('error') && $this->move_error)
|
|
||||||
// {
|
|
||||||
// @mkdir($path_error . '/' . $name);
|
|
||||||
// }
|
|
||||||
|
|
||||||
$ret |= $this->removeBadGroups($dom, $n, $path . '/' . $name
|
$ret |= $this->removeBadGroups($dom, $n, $path . '/' . $name
|
||||||
, $path_archived . '/' . $name
|
, $path_archived . '/' . $name
|
||||||
, $path_error . '/' . $name
|
, $path_error . '/' . $name
|
||||||
@@ -1086,7 +1065,7 @@ class task_period_archive extends task_abstract
|
|||||||
* @param <type> $depth
|
* @param <type> $depth
|
||||||
* @return <type>
|
* @return <type>
|
||||||
*/
|
*/
|
||||||
function archive($dom, $node, $path, $path_archived, $path_error, $depth=0)
|
function archive($dom, $node, $path, $path_archived, $path_error, $depth = 0)
|
||||||
{
|
{
|
||||||
static $iloop = 0;
|
static $iloop = 0;
|
||||||
if ($depth == 0)
|
if ($depth == 0)
|
||||||
@@ -1125,7 +1104,6 @@ class task_period_archive extends task_abstract
|
|||||||
$this->archiveFile($dom, $n, $path, $path_archived, $path_error, $nodesToDel, 0); // 0 = no grp
|
$this->archiveFile($dom, $n, $path, $path_archived, $path_error, $nodesToDel, 0); // 0 = no grp
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// printf("========== %s === %s ====== \n", __LINE__, var_export($nodesToDel, true));
|
|
||||||
foreach ($nodesToDel as $n)
|
foreach ($nodesToDel as $n)
|
||||||
$n->parentNode->removeChild($n);
|
$n->parentNode->removeChild($n);
|
||||||
|
|
||||||
@@ -1153,7 +1131,7 @@ class task_period_archive extends task_abstract
|
|||||||
* @param <type> $depth
|
* @param <type> $depth
|
||||||
* @return <type>
|
* @return <type>
|
||||||
*/
|
*/
|
||||||
function bubbleResults($dom, $node, $path, $depth=0)
|
function bubbleResults($dom, $node, $path, $depth = 0)
|
||||||
{
|
{
|
||||||
static $iloop = 0;
|
static $iloop = 0;
|
||||||
if ($depth == 0)
|
if ($depth == 0)
|
||||||
@@ -1212,7 +1190,7 @@ class task_period_archive extends task_abstract
|
|||||||
* @param <type> $depth
|
* @param <type> $depth
|
||||||
* @return <type>
|
* @return <type>
|
||||||
*/
|
*/
|
||||||
function moveFiles($dom, $node, $path, $path_archived, $path_error, $depth=0)
|
function moveFiles($dom, $node, $path, $path_archived, $path_error, $depth = 0)
|
||||||
{
|
{
|
||||||
static $iloop = 0;
|
static $iloop = 0;
|
||||||
if ($depth == 0)
|
if ($depth == 0)
|
||||||
@@ -1567,7 +1545,7 @@ class task_period_archive extends task_abstract
|
|||||||
* @param <type> $grp_rid
|
* @param <type> $grp_rid
|
||||||
* @return <type>
|
* @return <type>
|
||||||
*/
|
*/
|
||||||
function archiveFile($dom, $node, $path, $path_archived, $path_error, &$nodesToDel, $grp_rid=0)
|
function archiveFile($dom, $node, $path, $path_archived, $path_error, &$nodesToDel, $grp_rid = 0)
|
||||||
{
|
{
|
||||||
$match = $node->getAttribute('match');
|
$match = $node->getAttribute('match');
|
||||||
if ($match == '*')
|
if ($match == '*')
|
||||||
@@ -1823,7 +1801,7 @@ class task_period_archive extends task_abstract
|
|||||||
* @param <type> $attributes
|
* @param <type> $attributes
|
||||||
* @param <type> $depth
|
* @param <type> $depth
|
||||||
*/
|
*/
|
||||||
function setAllChildren($dom, $node, $attributes, $depth=0)
|
function setAllChildren($dom, $node, $attributes, $depth = 0)
|
||||||
{
|
{
|
||||||
static $iloop = 0;
|
static $iloop = 0;
|
||||||
if ($depth == 0)
|
if ($depth == 0)
|
||||||
|
@@ -2,7 +2,7 @@
|
|||||||
/*
|
/*
|
||||||
* This file is part of Phraseanet
|
* This file is part of Phraseanet
|
||||||
*
|
*
|
||||||
* (c) 2005-2010 Alchemy
|
* (c) 2005-2012 Alchemy
|
||||||
*
|
*
|
||||||
* For the full copyright and license information, please view the LICENSE
|
* For the full copyright and license information, please view the LICENSE
|
||||||
* file that was distributed with this source code.
|
* file that was distributed with this source code.
|
||||||
@@ -381,7 +381,7 @@ class task_period_cindexer extends task_abstract
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ( ! file_exists($cmd) || ! is_executable($cmd)) {
|
if ( ! file_exists($cmd) || ! is_executable($cmd)) {
|
||||||
$this->setState(self::STATUS_STOPPED);
|
$this->setState(self::STATE_STOPPED);
|
||||||
$this->log(sprintf(_('task::cindexer:file \'%s\' does not exists'), $cmd));
|
$this->log(sprintf(_('task::cindexer:file \'%s\' does not exists'), $cmd));
|
||||||
throw new Exception('cindexer executable not found', self::ERR_EXECUTABLE_NOT_FOUND);
|
throw new Exception('cindexer executable not found', self::ERR_EXECUTABLE_NOT_FOUND);
|
||||||
return;
|
return;
|
||||||
@@ -442,8 +442,6 @@ class task_period_cindexer extends task_abstract
|
|||||||
$nullfile = $this->system == 'WINDOWS' ? 'NUL' : '/dev/null';
|
$nullfile = $this->system == 'WINDOWS' ? 'NUL' : '/dev/null';
|
||||||
|
|
||||||
$descriptors = array();
|
$descriptors = array();
|
||||||
// $descriptors[1] = array("file", $logdir . "/phraseanet_indexer_" . $this->getID() . ".log", "a+");
|
|
||||||
// $descriptors[2] = array("file", $logdir . "/phraseanet_indexer_" . $this->getID() . ".error.log", "a+");
|
|
||||||
$descriptors[1] = array("file", $nullfile, "a+");
|
$descriptors[1] = array("file", $nullfile, "a+");
|
||||||
$descriptors[2] = array("file", $nullfile, "a+");
|
$descriptors[2] = array("file", $nullfile, "a+");
|
||||||
|
|
||||||
@@ -465,7 +463,7 @@ class task_period_cindexer extends task_abstract
|
|||||||
$this->running = true;
|
$this->running = true;
|
||||||
|
|
||||||
while ($this->running) {
|
while ($this->running) {
|
||||||
if ($this->getState() == self::STATUS_TOSTOP && $this->socket > 0) {
|
if ($this->getState() == self::STATE_TOSTOP && $this->socket > 0) {
|
||||||
// must quit task, so send 'Q' to port 127.0.0.1:XXXX to cindexer
|
// must quit task, so send 'Q' to port 127.0.0.1:XXXX to cindexer
|
||||||
if ( ! $qsent && (($sock = socket_create(AF_INET, SOCK_STREAM, 0)) !== false)) {
|
if ( ! $qsent && (($sock = socket_create(AF_INET, SOCK_STREAM, 0)) !== false)) {
|
||||||
if (socket_connect($sock, '127.0.0.1', $this->socket) === true) {
|
if (socket_connect($sock, '127.0.0.1', $this->socket) === true) {
|
||||||
@@ -487,10 +485,10 @@ class task_period_cindexer extends task_abstract
|
|||||||
// the cindexer died
|
// the cindexer died
|
||||||
if ($qsent == 'Q') {
|
if ($qsent == 'Q') {
|
||||||
$this->log(_('task::cindexer:the cindexer clean-quit'));
|
$this->log(_('task::cindexer:the cindexer clean-quit'));
|
||||||
$this->new_status = self::STATUS_STOPPED;
|
$this->new_status = self::STATE_STOPPED;
|
||||||
} elseif ($qsent == 'K') {
|
} elseif ($qsent == 'K') {
|
||||||
$this->log(_('task::cindexer:the cindexer has been killed'));
|
$this->log(_('task::cindexer:the cindexer has been killed'));
|
||||||
$this->new_status = self::STATUS_STOPPED;
|
$this->new_status = self::STATE_STOPPED;
|
||||||
} else {
|
} else {
|
||||||
$this->log(_('task::cindexer:the cindexer crashed'));
|
$this->log(_('task::cindexer:the cindexer crashed'));
|
||||||
$this->exception = new Exception('cindexer crashed', self::ERR_CRASHED);
|
$this->exception = new Exception('cindexer crashed', self::ERR_CRASHED);
|
||||||
@@ -536,7 +534,6 @@ class task_period_cindexer extends task_abstract
|
|||||||
} elseif ($pid == 0) {
|
} elseif ($pid == 0) {
|
||||||
// child
|
// child
|
||||||
umask(0);
|
umask(0);
|
||||||
// openlog('MyLog', LOG_PID | LOG_PERROR, LOG_LOCAL0);
|
|
||||||
if (($err = posix_setsid()) < 0) {
|
if (($err = posix_setsid()) < 0) {
|
||||||
$this->exception = new Exception('cindexer can\'t detach from terminal', $err);
|
$this->exception = new Exception('cindexer can\'t detach from terminal', $err);
|
||||||
} else {
|
} else {
|
||||||
@@ -562,7 +559,7 @@ class task_period_cindexer extends task_abstract
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->getState() == self::STATUS_TOSTOP) {
|
if ($this->getState() == self::STATE_TOSTOP) {
|
||||||
posix_kill($pid, ($sigsent = SIGINT));
|
posix_kill($pid, ($sigsent = SIGINT));
|
||||||
sleep(2);
|
sleep(2);
|
||||||
}
|
}
|
||||||
@@ -572,10 +569,10 @@ class task_period_cindexer extends task_abstract
|
|||||||
// child (indexer) has exited
|
// child (indexer) has exited
|
||||||
if ($sigsent == SIGINT) {
|
if ($sigsent == SIGINT) {
|
||||||
$this->log(_('task::cindexer:the cindexer clean-quit'));
|
$this->log(_('task::cindexer:the cindexer clean-quit'));
|
||||||
$this->new_status = self::STATUS_STOPPED;
|
$this->new_status = self::STATE_STOPPED;
|
||||||
} elseif ($sigsent == SIGKILL) {
|
} elseif ($sigsent == SIGKILL) {
|
||||||
$this->log(_('task::cindexer:the cindexer has been killed'));
|
$this->log(_('task::cindexer:the cindexer has been killed'));
|
||||||
$this->new_status = self::STATUS_STOPPED;
|
$this->new_status = self::STATE_STOPPED;
|
||||||
} else {
|
} else {
|
||||||
$this->log(_('task::cindexer:the cindexer crashed'));
|
$this->log(_('task::cindexer:the cindexer crashed'));
|
||||||
$this->exception = new Exception('cindexer crashed', self::ERR_CRASHED);
|
$this->exception = new Exception('cindexer crashed', self::ERR_CRASHED);
|
||||||
@@ -601,5 +598,3 @@ class task_period_cindexer extends task_abstract
|
|||||||
sleep(2);
|
sleep(2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// class
|
|
||||||
|
@@ -18,9 +18,7 @@
|
|||||||
class task_period_emptyColl extends task_appboxAbstract
|
class task_period_emptyColl extends task_appboxAbstract
|
||||||
{
|
{
|
||||||
protected $base_id;
|
protected $base_id;
|
||||||
|
|
||||||
protected $suicidable = true;
|
protected $suicidable = true;
|
||||||
|
|
||||||
protected $total_records = 0;
|
protected $total_records = 0;
|
||||||
|
|
||||||
public function getName()
|
public function getName()
|
||||||
@@ -47,9 +45,8 @@ class task_period_emptyColl extends task_appboxAbstract
|
|||||||
protected function retrieveContent(appbox $appbox)
|
protected function retrieveContent(appbox $appbox)
|
||||||
{
|
{
|
||||||
if ( ! $this->base_id) {
|
if ( ! $this->base_id) {
|
||||||
$this->current_state = self::STATE_FINISHED;
|
$this->setState(self::STATE_STOPPED);
|
||||||
|
return array();
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
$collection = collection::get_from_base_id($this->base_id);
|
$collection = collection::get_from_base_id($this->base_id);
|
||||||
$this->total_records = $collection->get_record_amount();
|
$this->total_records = $collection->get_record_amount();
|
||||||
@@ -58,7 +55,7 @@ class task_period_emptyColl extends task_appboxAbstract
|
|||||||
$this->setProgress($this->records_done, $this->total_records);
|
$this->setProgress($this->records_done, $this->total_records);
|
||||||
|
|
||||||
if ($this->total_records == 0) {
|
if ($this->total_records == 0) {
|
||||||
$this->current_state = self::STATE_FINISHED;
|
$this->setState(self::STATE_STOPPED);
|
||||||
$this->log('Job finished');
|
$this->log('Job finished');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -17,9 +17,7 @@
|
|||||||
class task_period_ftp extends task_appboxAbstract
|
class task_period_ftp extends task_appboxAbstract
|
||||||
{
|
{
|
||||||
protected $proxy;
|
protected $proxy;
|
||||||
|
|
||||||
protected $proxyport;
|
protected $proxyport;
|
||||||
|
|
||||||
protected $debug;
|
protected $debug;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -566,8 +564,7 @@ class task_period_ftp extends task_appboxAbstract
|
|||||||
{
|
{
|
||||||
$conn = $appbox->get_connection();
|
$conn = $appbox->get_connection();
|
||||||
|
|
||||||
$sql = 'SELECT crash, nbretry FROM ftp_export'
|
$sql = 'SELECT crash, nbretry FROM ftp_export WHERE id = :export_id';
|
||||||
. ' WHERE id = :export_id';
|
|
||||||
|
|
||||||
$stmt = $conn->prepare($sql);
|
$stmt = $conn->prepare($sql);
|
||||||
$stmt->execute(array(':export_id' => $id));
|
$stmt->execute(array(':export_id' => $id));
|
||||||
|
@@ -2,7 +2,7 @@
|
|||||||
/*
|
/*
|
||||||
* This file is part of Phraseanet
|
* This file is part of Phraseanet
|
||||||
*
|
*
|
||||||
* (c) 2005-2010 Alchemy
|
* (c) 2005-2012 Alchemy
|
||||||
*
|
*
|
||||||
* For the full copyright and license information, please view the LICENSE
|
* For the full copyright and license information, please view the LICENSE
|
||||||
* file that was distributed with this source code.
|
* file that was distributed with this source code.
|
||||||
@@ -17,25 +17,15 @@
|
|||||||
class task_period_ftpPull extends task_appboxAbstract
|
class task_period_ftpPull extends task_appboxAbstract
|
||||||
{
|
{
|
||||||
protected $debug = false;
|
protected $debug = false;
|
||||||
|
|
||||||
protected $proxy;
|
protected $proxy;
|
||||||
|
|
||||||
protected $proxyport;
|
protected $proxyport;
|
||||||
|
|
||||||
protected $host;
|
protected $host;
|
||||||
|
|
||||||
protected $port;
|
protected $port;
|
||||||
|
|
||||||
protected $user;
|
protected $user;
|
||||||
|
|
||||||
protected $password;
|
protected $password;
|
||||||
|
|
||||||
protected $ssl;
|
protected $ssl;
|
||||||
|
|
||||||
protected $passive;
|
protected $passive;
|
||||||
|
|
||||||
protected $ftppath;
|
protected $ftppath;
|
||||||
|
|
||||||
protected $localpath;
|
protected $localpath;
|
||||||
|
|
||||||
public function getName()
|
public function getName()
|
||||||
@@ -108,6 +98,7 @@ class task_period_ftpPull extends task_appboxAbstract
|
|||||||
<?php echo $form ?>.ssl.checked = <?php echo p4field::isyes($sxml->ssl) ? "true" : 'false' ?>;
|
<?php echo $form ?>.ssl.checked = <?php echo p4field::isyes($sxml->ssl) ? "true" : 'false' ?>;
|
||||||
<?php echo $form ?>.passive.checked = <?php echo p4field::isyes($sxml->passive) ? "true" : 'false' ?>;
|
<?php echo $form ?>.passive.checked = <?php echo p4field::isyes($sxml->passive) ? "true" : 'false' ?>;
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<?php
|
<?php
|
||||||
return("");
|
return("");
|
||||||
} else { // ... so we NEVER come here
|
} else { // ... so we NEVER come here
|
||||||
@@ -134,6 +125,7 @@ class task_period_ftpPull extends task_appboxAbstract
|
|||||||
setDirty();
|
setDirty();
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<?php
|
<?php
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -203,11 +195,11 @@ class task_period_ftpPull extends task_appboxAbstract
|
|||||||
|
|
||||||
if ($parm["xml"] === null) {
|
if ($parm["xml"] === null) {
|
||||||
// pas de xml 'raw' : on accepte les champs 'graphic view'
|
// pas de xml 'raw' : on accepte les champs 'graphic view'
|
||||||
if ($domTaskSettings = DOMDocument::loadXML($taskrow["settings"])) {
|
if (($domTaskSettings = DOMDocument::loadXML($taskrow["settings"]))) {
|
||||||
$xmlchanged = false;
|
$xmlchanged = false;
|
||||||
foreach (array("proxy", "proxyport", "period", "host", "port", "user", "password", "ssl", "passive", "localpath", "ftppath") as $f) {
|
foreach (array("proxy", "proxyport", "period", "host", "port", "user", "password", "ssl", "passive", "localpath", "ftppath") as $f) {
|
||||||
if ($parm[$f] !== NULL) {
|
if ($parm[$f] !== NULL) {
|
||||||
if ($ns = $domTaskSettings->getElementsByTagName($f)->item(0)) {
|
if (($ns = $domTaskSettings->getElementsByTagName($f)->item(0))) {
|
||||||
// le champ existait dans le xml, on supprime son ancienne valeur (tout le contenu)
|
// le champ existait dans le xml, on supprime son ancienne valeur (tout le contenu)
|
||||||
while (($n = $ns->firstChild))
|
while (($n = $ns->firstChild))
|
||||||
$ns->removeChild($n);
|
$ns->removeChild($n);
|
||||||
@@ -228,8 +220,9 @@ class task_period_ftpPull extends task_appboxAbstract
|
|||||||
}
|
}
|
||||||
|
|
||||||
// si on doit changer le xml, on verifie qu'il est valide
|
// si on doit changer le xml, on verifie qu'il est valide
|
||||||
if ($parm["xml"] && ! DOMDocument::loadXML($parm["xml"]))
|
if ($parm["xml"] && ! DOMDocument::loadXML($parm["xml"])) {
|
||||||
return(false);
|
return(false);
|
||||||
|
}
|
||||||
|
|
||||||
$sql = "";
|
$sql = "";
|
||||||
$params = array(':task_id' => $taskid);
|
$params = array(':task_id' => $taskid);
|
||||||
@@ -295,7 +288,7 @@ class task_period_ftpPull extends task_appboxAbstract
|
|||||||
$this->running = FALSE;
|
$this->running = FALSE;
|
||||||
}
|
}
|
||||||
if ( ! $this->running) {
|
if ( ! $this->running) {
|
||||||
$this->set_status(self::STATUS_STOPPED);
|
$this->set_status(self::STATE_STOPPED);
|
||||||
return array();
|
return array();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -308,14 +301,16 @@ class task_period_ftpPull extends task_appboxAbstract
|
|||||||
$todo = count($list_1);
|
$todo = count($list_1);
|
||||||
$this->setProgress($done, $todo);
|
$this->setProgress($done, $todo);
|
||||||
|
|
||||||
if ($this->debug)
|
if ($this->debug) {
|
||||||
echo "attente de 25sec pour avoir les fichiers froids...\n";
|
echo "attente de 25sec pour avoir les fichiers froids...\n";
|
||||||
|
}
|
||||||
|
|
||||||
for ($t = 25; $this->running && $t > 0; $t -- ) { // DON'T do sleep($this->period - $when_started) because it prevents ticks !
|
for ($t = 25; $this->running && $t > 0; $t -- ) { // DON'T do sleep($this->period - $when_started) because it prevents ticks !
|
||||||
$s = $this->getState();
|
$s = $this->getState();
|
||||||
if ($s == self::STATUS_TOSTOP) {
|
if ($s == self::STATE_TOSTOP) {
|
||||||
if (isset($ftp) && $ftp instanceof ftpclient)
|
if (isset($ftp) && $ftp instanceof ftpclient)
|
||||||
$ftp->close();
|
$ftp->close();
|
||||||
$this->set_status(self::STATUS_STOPPED);
|
$this->set_status(self::STATE_STOPPED);
|
||||||
$this->running = FALSE;
|
$this->running = FALSE;
|
||||||
return array();
|
return array();
|
||||||
}
|
}
|
||||||
@@ -379,3 +374,4 @@ class task_period_ftpPull extends task_appboxAbstract
|
|||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -2,7 +2,7 @@
|
|||||||
/*
|
/*
|
||||||
* This file is part of Phraseanet
|
* This file is part of Phraseanet
|
||||||
*
|
*
|
||||||
* (c) 2005-2010 Alchemy
|
* (c) 2005-2012 Alchemy
|
||||||
*
|
*
|
||||||
* For the full copyright and license information, please view the LICENSE
|
* For the full copyright and license information, please view the LICENSE
|
||||||
* file that was distributed with this source code.
|
* file that was distributed with this source code.
|
||||||
@@ -448,11 +448,8 @@ class task_period_outofdate extends task_abstract
|
|||||||
// ======================================================================================================
|
// ======================================================================================================
|
||||||
|
|
||||||
protected $sxTaskSettings = null; // les settings de la tache en simplexml
|
protected $sxTaskSettings = null; // les settings de la tache en simplexml
|
||||||
|
|
||||||
private $connbas = null; // cnx a la base
|
private $connbas = null; // cnx a la base
|
||||||
|
|
||||||
private $msg = "";
|
private $msg = "";
|
||||||
|
|
||||||
private $sbas_id;
|
private $sbas_id;
|
||||||
|
|
||||||
protected function run2()
|
protected function run2()
|
||||||
@@ -529,11 +526,11 @@ class task_period_outofdate extends task_abstract
|
|||||||
|
|
||||||
switch ($r) {
|
switch ($r) {
|
||||||
case 'WAIT':
|
case 'WAIT':
|
||||||
$ret = self::STATUS_STOPPED;
|
$this->setState(self::STATE_STOPPED);
|
||||||
$this->running = false;
|
$this->running = false;
|
||||||
break;
|
break;
|
||||||
case 'BAD':
|
case 'BAD':
|
||||||
$ret = self::STATUS_STOPPED;
|
$this->setState(self::STATE_STOPPED);
|
||||||
$this->running = false;
|
$this->running = false;
|
||||||
break;
|
break;
|
||||||
case 'NORECSTODO':
|
case 'NORECSTODO':
|
||||||
@@ -546,21 +543,21 @@ class task_period_outofdate extends task_abstract
|
|||||||
case 'MAXRECSDONE':
|
case 'MAXRECSDONE':
|
||||||
case 'MAXMEMORY':
|
case 'MAXMEMORY':
|
||||||
case 'MAXLOOP':
|
case 'MAXLOOP':
|
||||||
if ($row['status'] == self::STATUS_STARTED && $this->getRunner() !== self::RUNNER_MANUAL) {
|
if ($row['status'] == self::STATE_STARTED && $this->getRunner() !== self::RUNNER_MANUAL) {
|
||||||
$ret = self::STATUS_TORESTART;
|
$this->setState(self::STATE_TORESTART);
|
||||||
$this->running = false;
|
$this->running = false;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
if ($row['status'] == self::STATUS_STARTED) {
|
if ($row['status'] == self::STATE_STARTED) {
|
||||||
$ret = self::STATUS_STOPPED;
|
$this->setState(self::STATE_STOPPED);
|
||||||
$this->running = false;
|
$this->running = false;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$ret = self::STATUS_STOPPED;
|
$this->setState(self::STATE_STOPPED);
|
||||||
$this->running = false;
|
$this->running = false;
|
||||||
}
|
}
|
||||||
$loop ++;
|
$loop ++;
|
||||||
|
@@ -2,7 +2,7 @@
|
|||||||
/*
|
/*
|
||||||
* This file is part of Phraseanet
|
* This file is part of Phraseanet
|
||||||
*
|
*
|
||||||
* (c) 2005-2010 Alchemy
|
* (c) 2005-2012 Alchemy
|
||||||
*
|
*
|
||||||
* For the full copyright and license information, please view the LICENSE
|
* For the full copyright and license information, please view the LICENSE
|
||||||
* file that was distributed with this source code.
|
* file that was distributed with this source code.
|
||||||
@@ -141,6 +141,7 @@ class task_period_subdef extends task_databoxAbstract
|
|||||||
<?php echo $form ?>.maxrecs.value = "<?php echo p4string::MakeString($sxml->maxrecs, "js", '"') ?>";
|
<?php echo $form ?>.maxrecs.value = "<?php echo p4string::MakeString($sxml->maxrecs, "js", '"') ?>";
|
||||||
<?php echo $form ?>.maxmegs.value = "<?php echo p4string::MakeString($sxml->maxmegs, "js", '"') ?>";
|
<?php echo $form ?>.maxmegs.value = "<?php echo p4string::MakeString($sxml->maxmegs, "js", '"') ?>";
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<?php
|
<?php
|
||||||
return("");
|
return("");
|
||||||
}
|
}
|
||||||
@@ -261,7 +262,7 @@ class task_period_subdef extends task_databoxAbstract
|
|||||||
, $this->sbas_id, $record_id));
|
, $this->sbas_id, $record_id));
|
||||||
$record = new record_adapter($this->sbas_id, $record_id);
|
$record = new record_adapter($this->sbas_id, $record_id);
|
||||||
|
|
||||||
$record->generate_subdefs($databox, null, $this->debug);
|
$record->generate_subdefs($databox, null);
|
||||||
|
|
||||||
$this->recs_to_write[] = $record->get_record_id();
|
$this->recs_to_write[] = $record->get_record_id();
|
||||||
|
|
||||||
|
@@ -2,7 +2,7 @@
|
|||||||
/*
|
/*
|
||||||
* This file is part of Phraseanet
|
* This file is part of Phraseanet
|
||||||
*
|
*
|
||||||
* (c) 2005-2010 Alchemy
|
* (c) 2005-2012 Alchemy
|
||||||
*
|
*
|
||||||
* For the full copyright and license information, please view the LICENSE
|
* For the full copyright and license information, please view the LICENSE
|
||||||
* file that was distributed with this source code.
|
* file that was distributed with this source code.
|
||||||
@@ -10,7 +10,6 @@
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @package task_manager
|
|
||||||
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
|
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
|
||||||
* @link www.phraseanet.com
|
* @link www.phraseanet.com
|
||||||
*/
|
*/
|
||||||
@@ -117,12 +116,12 @@ class task_period_workflow01 extends task_databoxAbstract
|
|||||||
<?php echo $form ?>.period.value = "<?php echo p4string::MakeString($sxml->period, "js", '"') ?>";
|
<?php echo $form ?>.period.value = "<?php echo p4string::MakeString($sxml->period, "js", '"') ?>";
|
||||||
parent.calccmd();
|
parent.calccmd();
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<?php
|
<?php
|
||||||
return("");
|
return("");
|
||||||
}
|
}
|
||||||
else { // ... so we NEVER come here
|
else { // ... so we NEVER come here
|
||||||
// bad xml
|
// bad xml
|
||||||
|
|
||||||
return("BAD XML");
|
return("BAD XML");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -348,11 +347,8 @@ class task_period_workflow01 extends task_databoxAbstract
|
|||||||
return(_("task::outofdate:deplacement de docs suivant valeurs de champs 'date'"));
|
return(_("task::outofdate:deplacement de docs suivant valeurs de champs 'date'"));
|
||||||
}
|
}
|
||||||
protected $status_origine;
|
protected $status_origine;
|
||||||
|
|
||||||
protected $coll_origine;
|
protected $coll_origine;
|
||||||
|
|
||||||
protected $status_destination;
|
protected $status_destination;
|
||||||
|
|
||||||
protected $coll_destination;
|
protected $coll_destination;
|
||||||
|
|
||||||
protected function loadSettings(SimpleXMLElement $sx_task_settings)
|
protected function loadSettings(SimpleXMLElement $sx_task_settings)
|
||||||
@@ -382,28 +378,28 @@ class task_period_workflow01 extends task_databoxAbstract
|
|||||||
$sql_s = $sql_w = '';
|
$sql_s = $sql_w = '';
|
||||||
$sql_parms = array();
|
$sql_parms = array();
|
||||||
if ($this->coll_origine != '') {
|
if ($this->coll_origine != '') {
|
||||||
$sql_w .= ($sql_w ? ' AND ' : '')
|
$sql_w .= ($sql_w ? ' AND ' : '') . '(coll_id=:coll_org)';
|
||||||
. '(coll_id=:coll_org)';
|
|
||||||
$sql_parms[':coll_org'] = $this->coll_origine;
|
$sql_parms[':coll_org'] = $this->coll_origine;
|
||||||
}
|
}
|
||||||
if ($this->status_origine != '') {
|
if ($this->status_origine != '') {
|
||||||
$x = explode('_', $this->status_origine);
|
$x = explode('_', $this->status_origine);
|
||||||
if (count($x) !== 2)
|
if (count($x) !== 2) {
|
||||||
throw new Exception('Error in settings for status origine');
|
throw new Exception('Error in settings for status origin');
|
||||||
|
}
|
||||||
$sql_w .= ($sql_w ? ' AND ' : '')
|
$sql_w .= ($sql_w ? ' AND ' : '')
|
||||||
. '((status >> :stat_org_n & 1) = :stat_org_v)';
|
. '((status >> :stat_org_n & 1) = :stat_org_v)';
|
||||||
$sql_parms[':stat_org_n'] = $x[0];
|
$sql_parms[':stat_org_n'] = $x[0];
|
||||||
$sql_parms[':stat_org_v'] = $x[1];
|
$sql_parms[':stat_org_v'] = $x[1];
|
||||||
}
|
}
|
||||||
if ($this->coll_destination != '') {
|
if ($this->coll_destination != '') {
|
||||||
$sql_s .= ($sql_s ? ', ' : '')
|
$sql_s .= ($sql_s ? ', ' : '') . 'coll_id=:coll_dst';
|
||||||
. 'coll_id=:coll_dst';
|
|
||||||
$sql_parms[':coll_dst'] = $this->coll_destination;
|
$sql_parms[':coll_dst'] = $this->coll_destination;
|
||||||
}
|
}
|
||||||
if ($this->status_destination != '') {
|
if ($this->status_destination != '') {
|
||||||
$x = explode('_', $this->status_destination);
|
$x = explode('_', $this->status_destination);
|
||||||
if (count($x) !== 2)
|
if (count($x) !== 2) {
|
||||||
throw new Exception('Error in settings for status destination');
|
throw new Exception('Error in settings for status destination');
|
||||||
|
}
|
||||||
$sql_s .= ($sql_s ? ', ' : '');
|
$sql_s .= ($sql_s ? ', ' : '');
|
||||||
if ((int) $x[1] === 0)
|
if ((int) $x[1] === 0)
|
||||||
$sql_s .= 'status = status &~(1 << :stat_dst)';
|
$sql_s .= 'status = status &~(1 << :stat_dst)';
|
||||||
@@ -491,6 +487,7 @@ class task_period_workflow01 extends task_databoxAbstract
|
|||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return p4string::jsonencode($retjs);
|
return p4string::jsonencode($retjs);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -16,14 +16,12 @@ use PHPExiftool\Writer;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @package task_manager
|
|
||||||
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
|
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
|
||||||
* @link www.phraseanet.com
|
* @link www.phraseanet.com
|
||||||
*/
|
*/
|
||||||
class task_period_writemeta extends task_databoxAbstract
|
class task_period_writemeta extends task_databoxAbstract
|
||||||
{
|
{
|
||||||
protected $clear_doc;
|
protected $clear_doc;
|
||||||
|
|
||||||
protected $metasubdefs = array();
|
protected $metasubdefs = array();
|
||||||
|
|
||||||
function help()
|
function help()
|
||||||
@@ -61,7 +59,7 @@ class task_period_writemeta extends task_databoxAbstract
|
|||||||
$ptype = substr($pname, 0, 3);
|
$ptype = substr($pname, 0, 3);
|
||||||
$pname = substr($pname, 4);
|
$pname = substr($pname, 4);
|
||||||
$pvalue = $parm2[$pname];
|
$pvalue = $parm2[$pname];
|
||||||
if ($ns = $dom->getElementsByTagName($pname)->item(0)) {
|
if (($ns = $dom->getElementsByTagName($pname)->item(0))) {
|
||||||
// le champ existait dans le xml, on supprime son ancienne valeur (tout le contenu)
|
// le champ existait dans le xml, on supprime son ancienne valeur (tout le contenu)
|
||||||
while (($n = $ns->firstChild))
|
while (($n = $ns->firstChild))
|
||||||
$ns->removeChild($n);
|
$ns->removeChild($n);
|
||||||
|
@@ -293,7 +293,7 @@ class ApiJsonApplication extends PhraseanetWebTestCaseAbstract
|
|||||||
$this->evaluateMetaJson200($content);
|
$this->evaluateMetaJson200($content);
|
||||||
$task_manager->getTasks(true);
|
$task_manager->getTasks(true);
|
||||||
$task = $task_manager->getTask($idTask);
|
$task = $task_manager->getTask($idTask);
|
||||||
$this->assertEquals(\task_abstract::STATUS_TOSTART, $task->getState());
|
$this->assertEquals(\task_abstract::STATE_TOSTART, $task->getState());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -324,7 +324,7 @@ class ApiJsonApplication extends PhraseanetWebTestCaseAbstract
|
|||||||
$this->evaluateMetaJson200($content);
|
$this->evaluateMetaJson200($content);
|
||||||
$task_manager->getTasks(true);
|
$task_manager->getTasks(true);
|
||||||
$task = $task_manager->getTask($idTask);
|
$task = $task_manager->getTask($idTask);
|
||||||
$this->assertEquals(\task_abstract::STATUS_TOSTOP, $task->getState());
|
$this->assertEquals(\task_abstract::STATE_TOSTOP, $task->getState());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -294,7 +294,7 @@ class ApiYamlApplication extends PhraseanetWebTestCaseAbstract
|
|||||||
$this->evaluateMetaYaml200($content);
|
$this->evaluateMetaYaml200($content);
|
||||||
$task_manager->getTasks(true);
|
$task_manager->getTasks(true);
|
||||||
$task = $task_manager->getTask($idTask);
|
$task = $task_manager->getTask($idTask);
|
||||||
$this->assertEquals(\task_abstract::STATUS_TOSTART, $task->getState());
|
$this->assertEquals(\task_abstract::STATE_TOSTART, $task->getState());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -325,7 +325,7 @@ class ApiYamlApplication extends PhraseanetWebTestCaseAbstract
|
|||||||
$this->evaluateMetaYaml200($content);
|
$this->evaluateMetaYaml200($content);
|
||||||
$task_manager->getTasks(true);
|
$task_manager->getTasks(true);
|
||||||
$task = $task_manager->getTask($idTask);
|
$task = $task_manager->getTask($idTask);
|
||||||
$this->assertEquals(\task_abstract::STATUS_TOSTOP, $task->getState());
|
$this->assertEquals(\task_abstract::STATE_TOSTOP, $task->getState());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -3,7 +3,7 @@
|
|||||||
/*
|
/*
|
||||||
* This file is part of Phraseanet
|
* This file is part of Phraseanet
|
||||||
*
|
*
|
||||||
* (c) 2005-2010 Alchemy
|
* (c) 2005-2012 Alchemy
|
||||||
*
|
*
|
||||||
* For the full copyright and license information, please view the LICENSE
|
* For the full copyright and license information, please view the LICENSE
|
||||||
* file that was distributed with this source code.
|
* file that was distributed with this source code.
|
||||||
@@ -11,7 +11,6 @@
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @package
|
|
||||||
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
|
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
|
||||||
* @link www.phraseanet.com
|
* @link www.phraseanet.com
|
||||||
*/
|
*/
|
||||||
@@ -25,8 +24,7 @@ $parm = $request->get_parms('action', 'position', 'test', 'renew', 'path', 'test
|
|||||||
|
|
||||||
$output = '';
|
$output = '';
|
||||||
|
|
||||||
switch ($parm['action'])
|
switch ($parm['action']) {
|
||||||
{
|
|
||||||
case 'TREE':
|
case 'TREE':
|
||||||
$output = module_admin::getTree($parm['position']);
|
$output = module_admin::getTree($parm['position']);
|
||||||
break;
|
break;
|
||||||
@@ -37,25 +35,21 @@ switch ($parm['action'])
|
|||||||
$output = '0';
|
$output = '0';
|
||||||
break;
|
break;
|
||||||
case 'SCHEDULERKEY':
|
case 'SCHEDULERKEY':
|
||||||
$output = $registry->get('GV_ServerName') . 'admin/runscheduler.php?key=' . urlencode(phrasea::scheduler_key(!!$parm['renew']));
|
$output = $registry->get('GV_ServerName') . 'admin/runscheduler.php?key=' . urlencode(phrasea::scheduler_key( ! ! $parm['renew']));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'TESTPATH':
|
case 'TESTPATH':
|
||||||
$tests = true;
|
$tests = true;
|
||||||
foreach ($parm['tests'] as $test)
|
foreach ($parm['tests'] as $test) {
|
||||||
{
|
switch ($test) {
|
||||||
switch ($test)
|
|
||||||
{
|
|
||||||
case 'writeable':
|
case 'writeable':
|
||||||
if (!is_writable($parm['path']))
|
if ( ! is_writable($parm['path'])) {
|
||||||
{
|
|
||||||
$tests = false;
|
$tests = false;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 'readable':
|
case 'readable':
|
||||||
default:
|
default:
|
||||||
if (!is_readable($parm['path']))
|
if ( ! is_readable($parm['path'])) {
|
||||||
{
|
|
||||||
$tests = true;
|
$tests = true;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -67,30 +61,23 @@ switch ($parm['action'])
|
|||||||
case 'EMPTYBASE':
|
case 'EMPTYBASE':
|
||||||
$parm = $request->get_parms(array('sbas_id' => http_request::SANITIZE_NUMBER_INT));
|
$parm = $request->get_parms(array('sbas_id' => http_request::SANITIZE_NUMBER_INT));
|
||||||
$message = _('Base empty successful');
|
$message = _('Base empty successful');
|
||||||
try
|
try {
|
||||||
{
|
|
||||||
$sbas_id = (int) $parm['sbas_id'];
|
$sbas_id = (int) $parm['sbas_id'];
|
||||||
$databox = databox::get_instance($sbas_id);
|
$databox = databox::get_instance($sbas_id);
|
||||||
$class_name = 'task_period_emptyColl';
|
$class_name = 'task_period_emptyColl';
|
||||||
foreach ($databox->get_collections() as $collection)
|
foreach ($databox->get_collections() as $collection) {
|
||||||
{
|
if ($collection->get_record_amount() <= 500) {
|
||||||
if($collection->get_record_amount() <= 500)
|
|
||||||
{
|
|
||||||
$collection->empty_collection(500);
|
$collection->empty_collection(500);
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
$settings = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><tasksettings><base_id>" . $collection->get_base_id() . "</base_id></tasksettings>";
|
$settings = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><tasksettings><base_id>" . $collection->get_base_id() . "</base_id></tasksettings>";
|
||||||
task_abstract::create($appbox, $class_name, $settings);
|
task_abstract::create($appbox, $class_name, $settings);
|
||||||
$message = _('A task has been creted, please run it to complete empty collection');
|
$message = _('A task has been creted, please run it to complete empty collection');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
} catch (Exception $e) {
|
||||||
catch (Exception $e)
|
|
||||||
{
|
|
||||||
$message = _('An error occurred');
|
$message = _('An error occurred');
|
||||||
}
|
}
|
||||||
$output = p4string::jsonencode(array('message'=>$message));
|
$output = p4string::jsonencode(array('message' => $message));
|
||||||
break;
|
break;
|
||||||
case 'EMPTYCOLL':
|
case 'EMPTYCOLL':
|
||||||
$message = _('Collection empty successful');
|
$message = _('Collection empty successful');
|
||||||
@@ -100,45 +87,36 @@ switch ($parm['action'])
|
|||||||
, "coll_id" => http_request::SANITIZE_NUMBER_INT
|
, "coll_id" => http_request::SANITIZE_NUMBER_INT
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
try
|
try {
|
||||||
{
|
|
||||||
$databox = databox::get_instance($parm['sbas_id']);
|
$databox = databox::get_instance($parm['sbas_id']);
|
||||||
$collection = collection::get_from_coll_id($databox, $parm['coll_id']);
|
$collection = collection::get_from_coll_id($databox, $parm['coll_id']);
|
||||||
|
|
||||||
if($collection->get_record_amount() <= 500)
|
if ($collection->get_record_amount() <= 500) {
|
||||||
{
|
|
||||||
$collection->empty_collection(500);
|
$collection->empty_collection(500);
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
$class_name = 'task_period_emptyColl';
|
$class_name = 'task_period_emptyColl';
|
||||||
$settings = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<tasksettings>\n<base_id>" . $collection->get_base_id() . "</base_id></tasksettings>";
|
$settings = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<tasksettings>\n<base_id>" . $collection->get_base_id() . "</base_id></tasksettings>";
|
||||||
|
|
||||||
task_abstract::create($appbox, $class_name, $settings);
|
task_abstract::create($appbox, $class_name, $settings);
|
||||||
$message = _('A task has been creted, please run it to complete empty collection');
|
$message = _('A task has been creted, please run it to complete empty collection');
|
||||||
}
|
}
|
||||||
}
|
} catch (Exception $e) {
|
||||||
catch (Exception $e)
|
|
||||||
{
|
|
||||||
$message = _('An error occurred');
|
$message = _('An error occurred');
|
||||||
}
|
}
|
||||||
$output = p4string::jsonencode(array('message'=>$message));
|
$output = p4string::jsonencode(array('message' => $message));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'SETTASKSTATUS':
|
case 'SETTASKSTATUS':
|
||||||
$parm = $request->get_parms('task_id', 'status', 'signal');
|
$parm = $request->get_parms('task_id', 'status', 'signal');
|
||||||
try
|
try {
|
||||||
{
|
|
||||||
$task_manager = new task_manager($appbox);
|
$task_manager = new task_manager($appbox);
|
||||||
$task = $task_manager->getTask($parm['task_id']);
|
$task = $task_manager->getTask($parm['task_id']);
|
||||||
$pid = (int)($task->getPID());
|
$pid = (int) ($task->getPID());
|
||||||
$task->setState($parm["status"]);
|
$task->setState($parm["status"]);
|
||||||
$signal = (int)($parm['signal']);
|
$signal = (int) ($parm['signal']);
|
||||||
if( $signal > 0 && $pid )
|
if ($signal > 0 && $pid)
|
||||||
posix_kill($pid, $signal);
|
posix_kill($pid, $signal);
|
||||||
}
|
} catch (Exception $e) {
|
||||||
catch (Exception $e)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
}
|
||||||
$output = json_encode($pid);
|
$output = json_encode($pid);
|
||||||
@@ -146,28 +124,22 @@ switch ($parm['action'])
|
|||||||
|
|
||||||
case 'SETSCHEDSTATUS':
|
case 'SETSCHEDSTATUS':
|
||||||
$parm = $request->get_parms('status', 'signal');
|
$parm = $request->get_parms('status', 'signal');
|
||||||
try
|
try {
|
||||||
{
|
|
||||||
$task_manager = new task_manager($appbox);
|
$task_manager = new task_manager($appbox);
|
||||||
|
|
||||||
$task_manager->setSchedulerState($parm['status']);
|
$task_manager->setSchedulerState($parm['status']);
|
||||||
}
|
} catch (Exception $e) {
|
||||||
catch (Exception $e)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'RESETTASKCRASHCOUNTER':
|
case 'RESETTASKCRASHCOUNTER':
|
||||||
$parm = $request->get_parms("task_id");
|
$parm = $request->get_parms("task_id");
|
||||||
try
|
try {
|
||||||
{
|
|
||||||
$task_manager = new task_manager($appbox);
|
$task_manager = new task_manager($appbox);
|
||||||
$task = $task_manager->getTask($parm['task_id']);
|
$task = $task_manager->getTask($parm['task_id']);
|
||||||
$task->resetCrashCounter();
|
$task->resetCrashCounter();
|
||||||
}
|
} catch (Exception $e) {
|
||||||
catch (Exception $e)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
}
|
||||||
$ret = new DOMDocument("1.0", "UTF-8");
|
$ret = new DOMDocument("1.0", "UTF-8");
|
||||||
@@ -188,8 +160,7 @@ switch ($parm['action'])
|
|||||||
$root->setAttribute("saved", "0");
|
$root->setAttribute("saved", "0");
|
||||||
$root->appendChild($ret->createCDATASection(var_export($parm, true)));
|
$root->appendChild($ret->createCDATASection(var_export($parm, true)));
|
||||||
|
|
||||||
try
|
try {
|
||||||
{
|
|
||||||
$task_manager = new task_manager($appbox);
|
$task_manager = new task_manager($appbox);
|
||||||
$task = $task_manager->getTask($parm["task_id"]);
|
$task = $task_manager->getTask($parm["task_id"]);
|
||||||
/**
|
/**
|
||||||
@@ -198,50 +169,44 @@ switch ($parm['action'])
|
|||||||
$root->setAttribute("crashed", $task->getCrashCounter());
|
$root->setAttribute("crashed", $task->getCrashCounter());
|
||||||
if ($task->saveChanges($conn, $parm["task_id"], $row))
|
if ($task->saveChanges($conn, $parm["task_id"], $row))
|
||||||
$root->setAttribute("saved", "1");
|
$root->setAttribute("saved", "1");
|
||||||
}
|
} catch (Exception $e) {
|
||||||
catch (Exception $e)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$output = $ret->saveXML();
|
$output = $ret->saveXML();
|
||||||
break;
|
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->getSchedulerState();
|
$ret['scheduler'] = $task_manager->getSchedulerState();
|
||||||
|
|
||||||
$ret['tasks'] = array();
|
$ret['tasks'] = array();
|
||||||
|
|
||||||
foreach ($task_manager->getTasks(true) as $task)
|
foreach ($task_manager->getTasks(true) as $task) {
|
||||||
{
|
if ($task->getState() == task_abstract::STATE_TOSTOP && $task->getPID() === NULL) {
|
||||||
if($task->getState()==task_abstract::STATUS_TOSTOP && $task->getPID()===NULL)
|
|
||||||
{
|
|
||||||
// fix
|
// fix
|
||||||
$task->setState(task_abstract::STATUS_STOPPED);
|
$task->setState(task_abstract::STATE_STOPPED);
|
||||||
}
|
}
|
||||||
$id = $task->getID();
|
$id = $task->getID();
|
||||||
$ret['tasks'][$id] = array(
|
$ret['tasks'][$id] = array(
|
||||||
'id'=>$id
|
'id' => $id
|
||||||
, 'pid' =>$task->getPID()
|
, 'pid' => $task->getPID()
|
||||||
, 'crashed'=>$task->getCrashCounter()
|
, 'crashed' => $task->getCrashCounter()
|
||||||
, 'completed'=>$task->getCompletedPercentage()
|
, 'completed' => $task->getCompletedPercentage()
|
||||||
, 'status'=>$task->getState()
|
, 'status' => $task->getState()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(1)
|
if (1) {
|
||||||
{
|
|
||||||
$sql = 'SHOW PROCESSLIST';
|
$sql = 'SHOW PROCESSLIST';
|
||||||
$stmt = $appbox->get_connection()->prepare($sql);
|
$stmt = $appbox->get_connection()->prepare($sql);
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
$rows = $stmt->fetchALL(PDO::FETCH_ASSOC);
|
$rows = $stmt->fetchALL(PDO::FETCH_ASSOC);
|
||||||
$stmt->closeCursor();
|
$stmt->closeCursor();
|
||||||
$ret['db_processlist'] = array();
|
$ret['db_processlist'] = array();
|
||||||
foreach($rows as $row)
|
foreach ($rows as $row) {
|
||||||
{
|
if ($row['Info'] != $sql)
|
||||||
if($row['Info'] != $sql)
|
|
||||||
$ret['db_processlist'][] = $row;
|
$ret['db_processlist'][] = $row;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -351,25 +316,19 @@ switch ($parm['action'])
|
|||||||
|
|
||||||
$ret = array('sbas_id' => null, 'err' => -1, 'errmsg' => null);
|
$ret = array('sbas_id' => null, 'err' => -1, 'errmsg' => null);
|
||||||
|
|
||||||
try
|
try {
|
||||||
{
|
|
||||||
$sbas_id = (int) $parm['sbas_id'];
|
$sbas_id = (int) $parm['sbas_id'];
|
||||||
$databox = databox::get_instance($sbas_id);
|
$databox = databox::get_instance($sbas_id);
|
||||||
if ($databox->get_record_amount() == 0)
|
if ($databox->get_record_amount() == 0) {
|
||||||
{
|
|
||||||
$databox->unmount_databox($appbox);
|
$databox->unmount_databox($appbox);
|
||||||
$appbox->write_databox_pic($databox, null, databox::PIC_PDF);
|
$appbox->write_databox_pic($databox, null, databox::PIC_PDF);
|
||||||
$databox->delete();
|
$databox->delete();
|
||||||
$ret['sbas_id'] = $parm['sbas_id'];
|
$ret['sbas_id'] = $parm['sbas_id'];
|
||||||
$ret['err'] = 0;
|
$ret['err'] = 0;
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
$ret['errmsg'] = _('admin::base: vider la base avant de la supprimer');
|
$ret['errmsg'] = _('admin::base: vider la base avant de la supprimer');
|
||||||
}
|
}
|
||||||
}
|
} catch (Exception $e) {
|
||||||
catch (Exception $e)
|
|
||||||
{
|
|
||||||
$ret['errmsg'] = $e->getMessage();
|
$ret['errmsg'] = $e->getMessage();
|
||||||
}
|
}
|
||||||
$output = p4string::jsonencode($ret);
|
$output = p4string::jsonencode($ret);
|
||||||
|
@@ -2,7 +2,7 @@
|
|||||||
/*
|
/*
|
||||||
* This file is part of Phraseanet
|
* This file is part of Phraseanet
|
||||||
*
|
*
|
||||||
* (c) 2005-2010 Alchemy
|
* (c) 2005-2012 Alchemy
|
||||||
*
|
*
|
||||||
* For the full copyright and license information, please view the LICENSE
|
* For the full copyright and license information, please view the LICENSE
|
||||||
* file that was distributed with this source code.
|
* file that was distributed with this source code.
|
||||||
@@ -10,7 +10,6 @@
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @package
|
|
||||||
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
|
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
|
||||||
* @link www.phraseanet.com
|
* @link www.phraseanet.com
|
||||||
*/
|
*/
|
||||||
@@ -347,8 +346,6 @@ foreach ($tasks as $t) {
|
|||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
|
||||||
|
|
||||||
<?php ?>
|
|
||||||
<iframe id="zsched" src="about:blank" style="position:absolute; top:0px; left:0px; width:50px; height:50px; visibility:hidden"></iframe>
|
<iframe id="zsched" src="about:blank" style="position:absolute; top:0px; left:0px; width:50px; height:50px; visibility:hidden"></iframe>
|
||||||
|
|
||||||
<h1><?php echo _('admin::tasks: planificateur de taches') ?>
|
<h1><?php echo _('admin::tasks: planificateur de taches') ?>
|
||||||
@@ -422,11 +419,7 @@ foreach ($tasks as $t) {
|
|||||||
</table>
|
</table>
|
||||||
|
|
||||||
<div id="db_processlist"></div>
|
<div id="db_processlist"></div>
|
||||||
<!--
|
|
||||||
<a id="newTaskButton" href="#"><?php echo _('admin::tasks: Nouvelle tache') ?></a>
|
|
||||||
-->
|
|
||||||
|
|
||||||
<?php ?>
|
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
|
|
||||||
function editTask(tid)
|
function editTask(tid)
|
||||||
|
@@ -124,21 +124,21 @@ try {
|
|||||||
$status_2 = databox_status::operation_and($mask_oui, $mask_non);
|
$status_2 = databox_status::operation_and($mask_oui, $mask_non);
|
||||||
if ( ! $filename->is_new_in_base(phrasea::sbasFromBas($base_id)) || count($error_file) > 0) {
|
if ( ! $filename->is_new_in_base(phrasea::sbasFromBas($base_id)) || count($error_file) > 0) {
|
||||||
// file already exists in base
|
// file already exists in base
|
||||||
if ( ! lazaretFile::copy_uploaded_to_lazaret($filename, $base_id, $_FILES['Filedata']["name"], implode("\n", $error_file), $status_2)) {
|
if ( ! lazaretFile::move_uploaded_to_lazaret($filename, $base_id, $_FILES['Filedata']["name"], implode("\n", $error_file), $status_2)) {
|
||||||
// copy in lazaret failed
|
// move in lazaret failed
|
||||||
if (UPLOADER == 'FLASH')
|
if (UPLOADER == 'FLASH')
|
||||||
header('HTTP/1.1 500 Internal Server Error');
|
header('HTTP/1.1 500 Internal Server Error');
|
||||||
else
|
else
|
||||||
echo '<script type="text/javascript">parent.classic_uploaded("' . _("erreur lors de l'archivage") . '")</script>';
|
echo '<script type="text/javascript">parent.classic_uploaded("' . _("erreur lors de l'archivage") . '")</script>';
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// copy in lazaret succeed
|
// move in lazaret succeed
|
||||||
if (UPLOADER == 'HTML')
|
if (UPLOADER == 'HTML')
|
||||||
echo '<script type="text/javascript">parent.classic_uploaded("' . _('Document ajoute a la quarantaine') . '")</script>';
|
echo '<script type="text/javascript">parent.classic_uploaded("' . _('Document ajoute a la quarantaine') . '")</script>';
|
||||||
}
|
}
|
||||||
|
|
||||||
// if (UPLOADER == 'HTML')
|
if (UPLOADER == 'HTML')
|
||||||
// echo '<script type="text/javascript">parent.classic_uploaded("' . _("Fichier uploade, en attente") . '")</script>';
|
echo '<script type="text/javascript">parent.classic_uploaded("' . _("Fichier uploade, en attente") . '")</script>';
|
||||||
|
|
||||||
unset($filename);
|
unset($filename);
|
||||||
unlink($_FILES['Filedata']['tmp_name']);
|
unlink($_FILES['Filedata']['tmp_name']);
|
||||||
|
Reference in New Issue
Block a user