Update task manager log levels

This commit is contained in:
Romain Neutron
2014-02-03 15:04:31 +01:00
parent 142c221be2
commit 5b0fdb21f6
2 changed files with 13 additions and 13 deletions

View File

@@ -66,11 +66,11 @@ class task_Scheduler
$this->log(sprintf("SIGCHLD (%s) received from pid=%s, status=%s, exitstatus=%s", $signal, $pid, var_export($status, true), $exitstatus)); $this->log(sprintf("SIGCHLD (%s) received from pid=%s, status=%s, exitstatus=%s", $signal, $pid, var_export($status, true), $exitstatus));
break; break;
case SIGINT: // ctrl C case SIGINT: // ctrl C
$this->log(sprintf("SIGINT (%s) Ctrl-C received, schedstatus='tostop'", $signal)); $this->log(sprintf("SIGINT (%s) Ctrl-C received, schedstatus='tostop'", $signal), Logger::NOTICE);
$this->schedstatus = 'tostop'; $this->schedstatus = 'tostop';
break; break;
case SIGTERM: case SIGTERM:
$this->log(sprintf("SIGTERM (%s) received but ignored, http timeout ?", $signal)); $this->log(sprintf("SIGTERM (%s) received but ignored, http timeout ?", $signal), Logger::NOTICE);
break; break;
} }
} }
@@ -114,7 +114,7 @@ class task_Scheduler
$lockfile = ($lockdir . 'scheduler.lock'); $lockfile = ($lockdir . 'scheduler.lock');
if (($schedlock = fopen($lockfile, 'a+')) != FALSE) { if (($schedlock = fopen($lockfile, 'a+')) != FALSE) {
if (flock($schedlock, LOCK_EX | LOCK_NB) === FALSE) { if (flock($schedlock, LOCK_EX | LOCK_NB) === FALSE) {
$this->log(sprintf("failed to lock '%s' (try=%s/4)", $lockfile, $try), Logger::INFO); $this->log(sprintf("failed to lock '%s' (try=%s/4)", $lockfile, $try), Logger::NOTICE);
if ($try == 4) { if ($try == 4) {
$this->log("scheduler already running."); $this->log("scheduler already running.");
fclose($schedlock); fclose($schedlock);
@@ -182,7 +182,7 @@ class task_Scheduler
unset($conn); unset($conn);
if (! $connwaslost) { if (! $connwaslost) {
$this->log(sprintf("Warning : abox connection lost, restarting in 10 min."), Logger::INFO); $this->log(sprintf("Warning : abox connection lost, restarting in 10 min."), Logger::ERROR);
} }
for ($i = 0; $i < 60 * 10; $i ++) { for ($i = 0; $i < 60 * 10; $i ++) {
sleep(1); sleep(1);
@@ -196,7 +196,7 @@ class task_Scheduler
$connwaslost = true; $connwaslost = true;
} }
if ($connwaslost) { if ($connwaslost) {
$this->log("abox connection restored", Logger::INFO); $this->log("abox connection restored", Logger::NOTICE);
$sql = 'UPDATE task SET crashed=0'; $sql = 'UPDATE task SET crashed=0';
$stmt = $conn->prepare($sql); $stmt = $conn->prepare($sql);
@@ -235,7 +235,7 @@ class task_Scheduler
$stmt = $conn->prepare($sql); $stmt = $conn->prepare($sql);
$stmt->execute(); $stmt->execute();
$stmt->closeCursor(); $stmt->closeCursor();
$this->log("schedstatus == 'stopping', waiting tasks to end", Logger::INFO); $this->log("schedstatus == 'stopping', waiting tasks to end", Logger::NOTICE);
} }
// initialy, all tasks are supposed to be removed from the poll // initialy, all tasks are supposed to be removed from the poll
@@ -284,7 +284,7 @@ class task_Scheduler
"new Task %s, status=%s" "new Task %s, status=%s"
, $taskPoll[$tkey]["task"]->getID() , $taskPoll[$tkey]["task"]->getID()
, $status , $status
) ), Logger::NOTICE
); );
} else { } else {
// the task is already in the poll, update its status // the task is already in the poll, update its status
@@ -312,7 +312,7 @@ class task_Scheduler
// remove not-existing task from poll // remove not-existing task from poll
foreach ($taskPoll as $tkey => $task) { foreach ($taskPoll as $tkey => $task) {
if ($task["todel"]) { if ($task["todel"]) {
$this->log(sprintf("Task %s deleted", $taskPoll[$tkey]["task"]->getID())); $this->log(sprintf("Task %s deleted", $taskPoll[$tkey]["task"]->getID()), Logger::NOTICE);
unset($taskPoll[$tkey]); unset($taskPoll[$tkey]);
} }
} }
@@ -324,7 +324,7 @@ class task_Scheduler
$status = $tv['task']->getState(); $status = $tv['task']->getState();
switch ($status) { switch ($status) {
default: default:
$this->log(sprintf('Unknow status `%s`', $status)); $this->log(sprintf('Unknow status `%s`', $status), Logger::ERROR);
break; break;
case task_abstract::STATE_TORESTART: case task_abstract::STATE_TORESTART:
@@ -416,7 +416,7 @@ class task_Scheduler
, $taskPoll[$tkey]["task"]->getID() , $taskPoll[$tkey]["task"]->getID()
, $taskPoll[$tkey]["cmd"] , $taskPoll[$tkey]["cmd"]
, $taskPoll[$tkey]["task"]->getCrashCounter() , $taskPoll[$tkey]["task"]->getCrashCounter()
) ), Logger::ERROR
); );
if ($taskPoll[$tkey]["task"]->getCrashCounter() > 5) { if ($taskPoll[$tkey]["task"]->getCrashCounter() > 5) {
@@ -490,7 +490,7 @@ class task_Scheduler
"Task %s crashed %d times" "Task %s crashed %d times"
, $taskPoll[$tkey]["task"]->getID() , $taskPoll[$tkey]["task"]->getID()
, $taskPoll[$tkey]["task"]->getCrashCounter() , $taskPoll[$tkey]["task"]->getCrashCounter()
), Logger::INFO ), Logger::ERROR
); );
if ($taskPoll[$tkey]["task"]->getCrashCounter() > 5) { if ($taskPoll[$tkey]["task"]->getCrashCounter() > 5) {

View File

@@ -136,7 +136,7 @@ abstract class task_abstract
try { try {
$conn = connection::getPDOConnection($this->dependencyContainer); $conn = connection::getPDOConnection($this->dependencyContainer);
} catch (Exception $e) { } catch (Exception $e) {
$this->log(("Warning : abox connection lost : ".$e->getMessage().", restarting in 10 min."), self::LOG_DEBUG); $this->log(("Warning : abox connection lost : ".$e->getMessage().", restarting in 10 min."), self::LOG_ERROR);
$this->sleep(60 * 10); $this->sleep(60 * 10);
@@ -735,7 +735,7 @@ abstract class task_abstract
$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 %.02f M)", $this->maxmegs, ($current_memory >> 10) / 1024), self::LOG_ERROR); $this->log(sprintf("Max memory (%s M) reached (current is %.02f M)", $this->maxmegs, ($current_memory >> 10) / 1024), self::LOG_INFO);
$this->running = FALSE; $this->running = FALSE;
$ret = self::STATE_MAXMEGSREACHED; $ret = self::STATE_MAXMEGSREACHED;
} }