From 73eb8687ba5051e821e37ce2b71f8460d75557ae Mon Sep 17 00:00:00 2001 From: jygaulier Date: Thu, 24 May 2012 10:31:04 +0200 Subject: [PATCH] cleanup & removed mysql-process on task manager --- lib/classes/task/Scheduler.class.php | 1 + lib/classes/task/appboxAbstract.class.php | 98 +--------------------- lib/classes/task/databoxAbstract.class.php | 97 +-------------------- www/admin/adminFeedback.php | 3 +- www/admin/taskmanager.php | 13 +-- 5 files changed, 12 insertions(+), 200 deletions(-) diff --git a/lib/classes/task/Scheduler.class.php b/lib/classes/task/Scheduler.class.php index 47817d23e0..cb9c62336f 100755 --- a/lib/classes/task/Scheduler.class.php +++ b/lib/classes/task/Scheduler.class.php @@ -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 diff --git a/lib/classes/task/appboxAbstract.class.php b/lib/classes/task/appboxAbstract.class.php index 23109d0eb9..fff2bb772b 100755 --- a/lib/classes/task/appboxAbstract.class.php +++ b/lib/classes/task/appboxAbstract.class.php @@ -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; - */ } } diff --git a/lib/classes/task/databoxAbstract.class.php b/lib/classes/task/databoxAbstract.class.php index 3346902a17..31a353678a 100755 --- a/lib/classes/task/databoxAbstract.class.php +++ b/lib/classes/task/databoxAbstract.class.php @@ -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; - */ } } diff --git a/www/admin/adminFeedback.php b/www/admin/adminFeedback.php index c12142ee90..d74ceb8645 100755 --- a/www/admin/adminFeedback.php +++ b/www/admin/adminFeedback.php @@ -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(); diff --git a/www/admin/taskmanager.php b/www/admin/taskmanager.php index d191d5dc39..b4de1895ea 100755 --- a/www/admin/taskmanager.php +++ b/www/admin/taskmanager.php @@ -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) {