mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-10 19:43:16 +00:00
fix #977 (redirection vers collection dans task archive)
fix #969 (arrêt de la task d'archivage) fix #982 (symfony/process returnValue = -1)
This commit is contained in:
@@ -33,6 +33,7 @@ class task_Scheduler
|
|||||||
|
|
||||||
public function __construct(Logger $logger)
|
public function __construct(Logger $logger)
|
||||||
{
|
{
|
||||||
|
declare(ticks = 1);
|
||||||
$this->logger = $logger;
|
$this->logger = $logger;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -52,6 +53,14 @@ class task_Scheduler
|
|||||||
* @throws Exception if scheduler is already running
|
* @throws Exception if scheduler is already running
|
||||||
* @todo doc all possible exception
|
* @todo doc all possible exception
|
||||||
*/
|
*/
|
||||||
|
public function sigHandler($signal)
|
||||||
|
{
|
||||||
|
$status = null;
|
||||||
|
$pid = pcntl_wait($status);
|
||||||
|
$exitstatus = pcntl_wexitstatus ( $status );
|
||||||
|
$this->log(sprintf("sigchild %s received from pid=%s, status=%s, exitstatus=%s\n", $signal, $pid, var_export($status, true), $exitstatus));
|
||||||
|
}
|
||||||
|
|
||||||
public function run()
|
public function run()
|
||||||
{
|
{
|
||||||
|
|
||||||
@@ -73,7 +82,10 @@ class task_Scheduler
|
|||||||
|
|
||||||
if (\task_manager::isPosixPcntlSupported()) {
|
if (\task_manager::isPosixPcntlSupported()) {
|
||||||
// avoid <defunct> php when a task ends
|
// avoid <defunct> php when a task ends
|
||||||
pcntl_signal(SIGCHLD, SIG_IGN);
|
// pcntl_signal(SIGCHLD, SIG_IGN); // no zombies but no returnValue
|
||||||
|
// pcntl_signal(SIGCHLD, SIG_DFL); // with "declare(ticks=1)" returnValue ok but zombies
|
||||||
|
pcntl_signal(SIGCHLD, array($this, 'sigHandler')); // ok
|
||||||
|
|
||||||
$this->method = self::METHOD_FORK;
|
$this->method = self::METHOD_FORK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -145,7 +145,7 @@ class task_period_archive extends task_abstract
|
|||||||
public function xml2graphic($xml, $form)
|
public function xml2graphic($xml, $form)
|
||||||
{
|
{
|
||||||
// XML should always be valid here...
|
// XML should always be valid here...
|
||||||
if (($sxml = simplexml_load_string($xml)) != false) {
|
if ( ($sxml = simplexml_load_string($xml)) ) {
|
||||||
// sanitize values
|
// sanitize values
|
||||||
if ((int) ($sxml->period) < 10) {
|
if ((int) ($sxml->period) < 10) {
|
||||||
$sxml->period = 10;
|
$sxml->period = 10;
|
||||||
@@ -298,7 +298,7 @@ class task_period_archive extends task_abstract
|
|||||||
$this->period = 60;
|
$this->period = 60;
|
||||||
$this->cold = 30;
|
$this->cold = 30;
|
||||||
|
|
||||||
if (($this->sxBasePrefs = simplexml_load_string($collection->get_prefs())) != false) {
|
if ( ($this->sxBasePrefs = simplexml_load_string($collection->get_prefs())) ) {
|
||||||
$this->sxBasePrefs["id"] = $base_id;
|
$this->sxBasePrefs["id"] = $base_id;
|
||||||
|
|
||||||
$this->period = (int) ($this->sxTaskSettings->period);
|
$this->period = (int) ($this->sxTaskSettings->period);
|
||||||
@@ -397,7 +397,7 @@ class task_period_archive extends task_abstract
|
|||||||
|
|
||||||
$this->setLastExecTime();
|
$this->setLastExecTime();
|
||||||
try {
|
try {
|
||||||
if ( ! ($this->sxTaskSettings = @simplexml_load_string($this->getSettings()))) {
|
if ( !($this->sxTaskSettings = @simplexml_load_string($this->getSettings())) ) {
|
||||||
throw new Exception(sprintf('Error fetching or reading settings of the task \'%d\'', $this->getID()));
|
throw new Exception(sprintf('Error fetching or reading settings of the task \'%d\'', $this->getID()));
|
||||||
} else {
|
} else {
|
||||||
// copy settings to task, so it's easier to get later
|
// copy settings to task, so it's easier to get later
|
||||||
@@ -609,10 +609,10 @@ class task_period_archive extends task_abstract
|
|||||||
if ($this->movedFiles) {
|
if ($this->movedFiles) {
|
||||||
|
|
||||||
// something happened : a least one file has moved
|
// something happened : a least one file has moved
|
||||||
return self::STATE_MAXRECSDONE;
|
return 'MAXRECSDONE';
|
||||||
} elseif (memory_get_usage() >> 20 > 25) {
|
} elseif (memory_get_usage() >> 20 > 25) {
|
||||||
|
|
||||||
return self::STATE_MAXMEGSREACHED;
|
return 'MAXMEGSREACHED';
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
return 'NORECSTODO';
|
return 'NORECSTODO';
|
||||||
@@ -693,7 +693,7 @@ class task_period_archive extends task_abstract
|
|||||||
try {
|
try {
|
||||||
$listFolder = new CListFolder($path);
|
$listFolder = new CListFolder($path);
|
||||||
|
|
||||||
if (($sxDotPhrasea = @simplexml_load_file($path . '/.phrasea.xml')) != false) {
|
if ( ($sxDotPhrasea = @simplexml_load_file($path . '/.phrasea.xml')) ) {
|
||||||
|
|
||||||
// test for magic file
|
// test for magic file
|
||||||
if (($magicfile = trim((string) ($sxDotPhrasea->magicfile))) != '') {
|
if (($magicfile = trim((string) ($sxDotPhrasea->magicfile))) != '') {
|
||||||
@@ -800,7 +800,7 @@ class task_period_archive extends task_abstract
|
|||||||
|
|
||||||
$xp = new DOMXPath($dom);
|
$xp = new DOMXPath($dom);
|
||||||
|
|
||||||
if (($sxDotPhrasea = @simplexml_load_file($path . '/.phrasea.xml')) != false) {
|
if ( ($sxDotPhrasea = @simplexml_load_file($path . '/.phrasea.xml')) ) {
|
||||||
|
|
||||||
// test magicfile
|
// test magicfile
|
||||||
if (($magicfile = trim((string) ($sxDotPhrasea->magicfile))) != '') {
|
if (($magicfile = trim((string) ($sxDotPhrasea->magicfile))) != '') {
|
||||||
|
Reference in New Issue
Block a user