mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-10 11:33:17 +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
|
||||
* @link www.phraseanet.com
|
||||
*/
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
|
||||
class task_Scheduler
|
||||
|
@@ -123,106 +123,14 @@ abstract class task_appboxAbstract extends task_abstract
|
||||
try {
|
||||
// get the records to process
|
||||
$rs = $this->retrieveContent($appbox);
|
||||
|
||||
// process the records
|
||||
$ret = $this->processLoop($appbox, $rs);
|
||||
|
||||
} catch (Exception $e) {
|
||||
$this->log('Error : ' . $e->getMessage());
|
||||
}
|
||||
|
||||
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 {
|
||||
// get the records to process
|
||||
$rs = $this->retrieveSbasContent($databox);
|
||||
|
||||
// process the records
|
||||
$ret = $this->processLoop($databox, $rs);
|
||||
|
||||
} catch (Exception $e) {
|
||||
$this->log('Error : ' . $e->getMessage());
|
||||
}
|
||||
|
||||
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();
|
||||
break;
|
||||
case 'PINGSCHEDULER_JS':
|
||||
$parm = $request->get_parms('dbps');
|
||||
$ret = array('time' => date("H:i:s"));
|
||||
|
||||
$task_manager = new task_manager($appbox);
|
||||
@@ -201,7 +202,7 @@ switch ($parm['action']) {
|
||||
);
|
||||
}
|
||||
|
||||
if (1) {
|
||||
if ($parm['dbps']) {
|
||||
$sql = 'SHOW PROCESSLIST';
|
||||
$stmt = $appbox->get_connection()->prepare($sql);
|
||||
$stmt->execute();
|
||||
|
@@ -236,10 +236,6 @@ foreach ($tasks as $t) {
|
||||
{
|
||||
// theme:'vista',
|
||||
optionsIdx:{'start':0, 'stop':1},
|
||||
doclick:function(item)
|
||||
{
|
||||
console.log(item);
|
||||
},
|
||||
beforeShow:function()
|
||||
{
|
||||
if(!retPing)
|
||||
@@ -301,10 +297,6 @@ foreach ($tasks as $t) {
|
||||
],
|
||||
{
|
||||
optionsIdx:{'edit':0, 'start':1, 'stop':2, 'delete':3, 'log':5},
|
||||
doclick:function()
|
||||
{
|
||||
|
||||
},
|
||||
beforeShow:function()
|
||||
{
|
||||
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");
|
||||
|
||||
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");
|
||||
else
|
||||
$(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)
|
||||
{
|
||||
$.ajax({
|
||||
url: '/admin/adminFeedback.php?action=PINGSCHEDULER_JS',
|
||||
url: '/admin/adminFeedback.php',
|
||||
data:{action:'PINGSCHEDULER_JS', dbps:0},
|
||||
dataType:'json',
|
||||
success: function(ret)
|
||||
{
|
||||
|
Reference in New Issue
Block a user