mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-10 19:43:16 +00:00
Merge pull request #102 from jygaulier/TaskManager
cleanup & removed mysql-process on task manager
This commit is contained in:
@@ -14,6 +14,7 @@
|
|||||||
* @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\Console\Input\InputInterface;
|
||||||
use Symfony\Component\Console\Output\OutputInterface;
|
use Symfony\Component\Console\Output\OutputInterface;
|
||||||
|
|
||||||
class task_Scheduler
|
class task_Scheduler
|
||||||
|
@@ -123,106 +123,14 @@ abstract class task_appboxAbstract extends task_abstract
|
|||||||
try {
|
try {
|
||||||
// get the records to process
|
// get the records to process
|
||||||
$rs = $this->retrieveContent($appbox);
|
$rs = $this->retrieveContent($appbox);
|
||||||
|
|
||||||
|
// process the records
|
||||||
$ret = $this->processLoop($appbox, $rs);
|
$ret = $this->processLoop($appbox, $rs);
|
||||||
|
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
$this->log('Error : ' . $e->getMessage());
|
$this->log('Error : ' . $e->getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
return $ret;
|
return $ret;
|
||||||
|
|
||||||
/*
|
|
||||||
$ret = self::STATE_OK;
|
|
||||||
|
|
||||||
try {
|
|
||||||
// get the records to process
|
|
||||||
$rs = $this->retrieveContent($appbox);
|
|
||||||
} catch (Exception $e) {
|
|
||||||
$this->log('Error : ' . $e->getMessage());
|
|
||||||
$rs = array();
|
|
||||||
}
|
|
||||||
|
|
||||||
$rowstodo = count($rs);
|
|
||||||
$rowsdone = 0;
|
|
||||||
|
|
||||||
if ($rowstodo > 0) {
|
|
||||||
$this->setProgress(0, $rowstodo);
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach ($rs as $row) {
|
|
||||||
|
|
||||||
try {
|
|
||||||
// process one record
|
|
||||||
$this->processOneContent($appbox, $row);
|
|
||||||
} catch (Exception $e) {
|
|
||||||
$this->log("Exception : " . $e->getMessage() . " " . basename($e->getFile()) . " " . $e->getLine());
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->records_done ++;
|
|
||||||
$this->setProgress($rowsdone, $rowstodo);
|
|
||||||
|
|
||||||
// post-process
|
|
||||||
$this->postProcessOneContent($appbox, $row);
|
|
||||||
|
|
||||||
$current_memory = memory_get_usage();
|
|
||||||
if ($current_memory >> 20 >= $this->maxmegs) {
|
|
||||||
$this->log(sprintf("Max memory (%s M) reached (actual is %s M)", $this->maxmegs, $current_memory));
|
|
||||||
$this->running = FALSE;
|
|
||||||
$ret = self::STATE_MAXMEGSREACHED;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($this->records_done >= (int) ($this->maxrecs)) {
|
|
||||||
$this->log(sprintf("Max records done (%s) reached (actual is %s)", $this->maxrecs, $this->records_done));
|
|
||||||
$this->running = FALSE;
|
|
||||||
$ret = self::STATE_MAXRECSDONE;
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
$status = $this->getState();
|
|
||||||
if ($status == self::STATE_TOSTOP) {
|
|
||||||
$this->running = FALSE;
|
|
||||||
$ret = self::STATE_TOSTOP;
|
|
||||||
}
|
|
||||||
} catch (Exception $e) {
|
|
||||||
$this->running = FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( ! $this->running) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//
|
|
||||||
// if nothing was done, at least check the status
|
|
||||||
if (count($rs) == 0 && $this->running) {
|
|
||||||
|
|
||||||
$current_memory = memory_get_usage();
|
|
||||||
if ($current_memory >> 20 >= $this->maxmegs) {
|
|
||||||
$this->log(sprintf("Max memory (%s M) reached (current is %s M)", $this->maxmegs, $current_memory));
|
|
||||||
$this->running = FALSE;
|
|
||||||
$ret = self::STATE_MAXMEGSREACHED;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($this->records_done >= (int) ($this->maxrecs)) {
|
|
||||||
$this->log(sprintf("Max records done (%s) reached (actual is %s)", $this->maxrecs, $this->records_done));
|
|
||||||
$this->running = FALSE;
|
|
||||||
$ret = self::STATE_MAXRECSDONE;
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
$status = $this->getState();
|
|
||||||
if ($status == self::STATE_TOSTOP) {
|
|
||||||
$this->running = FALSE;
|
|
||||||
$ret = self::STATE_TOSTOP;
|
|
||||||
}
|
|
||||||
} catch (Exception $e) {
|
|
||||||
$this->running = FALSE;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($rowstodo > 0) {
|
|
||||||
$this->setProgress(0, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
return $ret;
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -161,106 +161,15 @@ abstract class task_databoxAbstract extends task_abstract
|
|||||||
try {
|
try {
|
||||||
// get the records to process
|
// get the records to process
|
||||||
$rs = $this->retrieveSbasContent($databox);
|
$rs = $this->retrieveSbasContent($databox);
|
||||||
|
|
||||||
|
// process the records
|
||||||
$ret = $this->processLoop($databox, $rs);
|
$ret = $this->processLoop($databox, $rs);
|
||||||
|
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
$this->log('Error : ' . $e->getMessage());
|
$this->log('Error : ' . $e->getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
return $ret;
|
return $ret;
|
||||||
/*
|
|
||||||
$ret = self::STATE_OK;
|
|
||||||
|
|
||||||
try {
|
|
||||||
// get the records to process
|
|
||||||
$rs = $this->retrieveSbasContent($databox);
|
|
||||||
} catch (Exception $e) {
|
|
||||||
$this->log('Error : ' . $e->getMessage());
|
|
||||||
$rs = array();
|
|
||||||
}
|
|
||||||
|
|
||||||
$rowstodo = count($rs);
|
|
||||||
$rowsdone = 0;
|
|
||||||
|
|
||||||
if ($rowstodo > 0) {
|
|
||||||
$this->setProgress(0, $rowstodo);
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach ($rs as $row) {
|
|
||||||
|
|
||||||
try {
|
|
||||||
// process one record
|
|
||||||
$this->processOneContent($databox, $row);
|
|
||||||
} catch (Exception $e) {
|
|
||||||
$this->log("Exception : " . $e->getMessage() . " " . basename($e->getFile()) . " " . $e->getLine());
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->records_done ++;
|
|
||||||
$this->setProgress($rowsdone, $rowstodo);
|
|
||||||
|
|
||||||
// post-process
|
|
||||||
$this->postProcessOneContent($databox, $row);
|
|
||||||
|
|
||||||
$current_memory = memory_get_usage();
|
|
||||||
if ($current_memory >> 20 >= $this->maxmegs) {
|
|
||||||
$this->log(sprintf("Max memory (%s M) reached (actual is %s M)", $this->maxmegs, $current_memory));
|
|
||||||
$this->running = FALSE;
|
|
||||||
$ret = self::STATE_MAXMEGSREACHED;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($this->records_done >= (int) ($this->maxrecs)) {
|
|
||||||
$this->log(sprintf("Max records done (%s) reached (actual is %s)", $this->maxrecs, $this->records_done));
|
|
||||||
$this->running = FALSE;
|
|
||||||
$ret = self::STATE_MAXRECSDONE;
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
$status = $this->getState();
|
|
||||||
if ($status == self::STATE_TOSTOP) {
|
|
||||||
$this->running = FALSE;
|
|
||||||
$ret = self::STATE_TOSTOP;
|
|
||||||
}
|
|
||||||
} catch (Exception $e) {
|
|
||||||
$this->running = FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( ! $this->running) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//
|
|
||||||
// if nothing was done, at least check the status
|
|
||||||
if (count($rs) == 0 && $this->running) {
|
|
||||||
|
|
||||||
$current_memory = memory_get_usage();
|
|
||||||
if ($current_memory >> 20 >= $this->maxmegs) {
|
|
||||||
$this->log(sprintf("Max memory (%s M) reached (current is %s M)", $this->maxmegs, $current_memory));
|
|
||||||
$this->running = FALSE;
|
|
||||||
$ret = self::STATE_MAXMEGSREACHED;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($this->records_done >= (int) ($this->maxrecs)) {
|
|
||||||
$this->log(sprintf("Max records done (%s) reached (actual is %s)", $this->maxrecs, $this->records_done));
|
|
||||||
$this->running = FALSE;
|
|
||||||
$ret = self::STATE_MAXRECSDONE;
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
$status = $this->getState();
|
|
||||||
if ($status == self::STATE_TOSTOP) {
|
|
||||||
$this->running = FALSE;
|
|
||||||
$ret = self::STATE_TOSTOP;
|
|
||||||
}
|
|
||||||
} catch (Exception $e) {
|
|
||||||
$this->running = FALSE;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($rowstodo > 0) {
|
|
||||||
$this->setProgress(0, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
return $ret;
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -179,6 +179,7 @@ switch ($parm['action']) {
|
|||||||
$output = $ret->saveXML();
|
$output = $ret->saveXML();
|
||||||
break;
|
break;
|
||||||
case 'PINGSCHEDULER_JS':
|
case 'PINGSCHEDULER_JS':
|
||||||
|
$parm = $request->get_parms('dbps');
|
||||||
$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);
|
||||||
@@ -201,7 +202,7 @@ switch ($parm['action']) {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (1) {
|
if ($parm['dbps']) {
|
||||||
$sql = 'SHOW PROCESSLIST';
|
$sql = 'SHOW PROCESSLIST';
|
||||||
$stmt = $appbox->get_connection()->prepare($sql);
|
$stmt = $appbox->get_connection()->prepare($sql);
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
|
@@ -236,10 +236,6 @@ foreach ($tasks as $t) {
|
|||||||
{
|
{
|
||||||
// theme:'vista',
|
// theme:'vista',
|
||||||
optionsIdx:{'start':0, 'stop':1},
|
optionsIdx:{'start':0, 'stop':1},
|
||||||
doclick:function(item)
|
|
||||||
{
|
|
||||||
console.log(item);
|
|
||||||
},
|
|
||||||
beforeShow:function()
|
beforeShow:function()
|
||||||
{
|
{
|
||||||
if(!retPing)
|
if(!retPing)
|
||||||
@@ -301,10 +297,6 @@ foreach ($tasks as $t) {
|
|||||||
],
|
],
|
||||||
{
|
{
|
||||||
optionsIdx:{'edit':0, 'start':1, 'stop':2, 'delete':3, 'log':5},
|
optionsIdx:{'edit':0, 'start':1, 'stop':2, 'delete':3, 'log':5},
|
||||||
doclick:function()
|
|
||||||
{
|
|
||||||
|
|
||||||
},
|
|
||||||
beforeShow:function()
|
beforeShow:function()
|
||||||
{
|
{
|
||||||
var tid = $($(this)[0].target).parent().attr('id').split('_').pop();
|
var tid = $($(this)[0].target).parent().attr('id').split('_').pop();
|
||||||
@@ -323,7 +315,7 @@ foreach ($tasks as $t) {
|
|||||||
{
|
{
|
||||||
$(this.menu).find('.context-menu-item:eq('+this.optionsIdx['edit']+')').removeClass("context-menu-item-disabled");
|
$(this.menu).find('.context-menu-item:eq('+this.optionsIdx['edit']+')').removeClass("context-menu-item-disabled");
|
||||||
|
|
||||||
if(retPing.tasks[tid].status == 'started')
|
if(retPing.tasks[tid].status == 'started' || retPing.tasks[tid].status == 'torestart')
|
||||||
$(this.menu).find('.context-menu-item:eq('+this.optionsIdx['stop']+')').removeClass("context-menu-item-disabled");
|
$(this.menu).find('.context-menu-item:eq('+this.optionsIdx['stop']+')').removeClass("context-menu-item-disabled");
|
||||||
else
|
else
|
||||||
$(this.menu).find('.context-menu-item:eq('+this.optionsIdx['stop']+')').addClass("context-menu-item-disabled");
|
$(this.menu).find('.context-menu-item:eq('+this.optionsIdx['stop']+')').addClass("context-menu-item-disabled");
|
||||||
@@ -484,7 +476,8 @@ foreach ($tasks as $t) {
|
|||||||
function pingScheduler(repeat)
|
function pingScheduler(repeat)
|
||||||
{
|
{
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: '/admin/adminFeedback.php?action=PINGSCHEDULER_JS',
|
url: '/admin/adminFeedback.php',
|
||||||
|
data:{action:'PINGSCHEDULER_JS', dbps:0},
|
||||||
dataType:'json',
|
dataType:'json',
|
||||||
success: function(ret)
|
success: function(ret)
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user