daemon: clarify some task-related messages
This commit is contained in:
parent
8cc07bc8bd
commit
2abc434e26
|
@ -218,7 +218,7 @@
|
||||||
|
|
||||||
if (isset($options["task"]) && isset($options["pidlock"])) {
|
if (isset($options["task"]) && isset($options["pidlock"])) {
|
||||||
$waits = $options["task"] * 5;
|
$waits = $options["task"] * 5;
|
||||||
Debug::log("Waiting before update ($waits)");
|
Debug::log("Waiting before update ($waits)...");
|
||||||
sleep($waits);
|
sleep($waits);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -58,12 +58,12 @@
|
||||||
if (file_is_locked("update_daemon-$pid.lock")) {
|
if (file_is_locked("update_daemon-$pid.lock")) {
|
||||||
array_push($tmp, $pid);
|
array_push($tmp, $pid);
|
||||||
} else {
|
} else {
|
||||||
Debug::log("[reap_children] child $pid seems active but lockfile is unlocked.");
|
Debug::log("Child process with PID $pid seems active but lockfile is unlocked.");
|
||||||
unset($ctimes[$pid]);
|
unset($ctimes[$pid]);
|
||||||
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Debug::log("[reap_children] child $pid reaped.");
|
Debug::log("Child process with PID $pid reaped.");
|
||||||
unset($ctimes[$pid]);
|
unset($ctimes[$pid]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -80,7 +80,7 @@
|
||||||
$started = $ctimes[$pid];
|
$started = $ctimes[$pid];
|
||||||
|
|
||||||
if (time() - $started > MAX_CHILD_RUNTIME) {
|
if (time() - $started > MAX_CHILD_RUNTIME) {
|
||||||
Debug::log("[MASTER] child process $pid seems to be stuck, aborting...");
|
Debug::log("Child process with PID $pid seems to be stuck, aborting...");
|
||||||
posix_kill($pid, SIGKILL);
|
posix_kill($pid, SIGKILL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -92,7 +92,7 @@
|
||||||
function sigchld_handler($signal) {
|
function sigchld_handler($signal) {
|
||||||
$running_jobs = reap_children();
|
$running_jobs = reap_children();
|
||||||
|
|
||||||
Debug::log("[SIGCHLD] jobs left: $running_jobs");
|
Debug::log("Received SIGCHLD, $running_jobs active tasks left.");
|
||||||
|
|
||||||
pcntl_waitpid(-1, $status, WNOHANG);
|
pcntl_waitpid(-1, $status, WNOHANG);
|
||||||
}
|
}
|
||||||
|
@ -100,7 +100,7 @@
|
||||||
function shutdown($caller_pid) {
|
function shutdown($caller_pid) {
|
||||||
if ($caller_pid == posix_getpid()) {
|
if ($caller_pid == posix_getpid()) {
|
||||||
if (file_exists(LOCK_DIRECTORY . "/update_daemon.lock")) {
|
if (file_exists(LOCK_DIRECTORY . "/update_daemon.lock")) {
|
||||||
Debug::log("removing lockfile (master)...");
|
Debug::log("Removing lockfile (master)...");
|
||||||
unlink(LOCK_DIRECTORY . "/update_daemon.lock");
|
unlink(LOCK_DIRECTORY . "/update_daemon.lock");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -110,19 +110,19 @@
|
||||||
$pid = posix_getpid();
|
$pid = posix_getpid();
|
||||||
|
|
||||||
if (file_exists(LOCK_DIRECTORY . "/update_daemon-$pid.lock")) {
|
if (file_exists(LOCK_DIRECTORY . "/update_daemon-$pid.lock")) {
|
||||||
Debug::log("removing lockfile ($pid)...");
|
Debug::log("Removing task lockfile for PID $pid...");
|
||||||
unlink(LOCK_DIRECTORY . "/update_daemon-$pid.lock");
|
unlink(LOCK_DIRECTORY . "/update_daemon-$pid.lock");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function sigint_handler() {
|
function sigint_handler() {
|
||||||
Debug::log("[MASTER] SIG_INT received.\n");
|
Debug::log("[MASTER] SIG_INT received, shutting down master process.");
|
||||||
shutdown(posix_getpid());
|
shutdown(posix_getpid());
|
||||||
die;
|
die;
|
||||||
}
|
}
|
||||||
|
|
||||||
function task_sigint_handler() {
|
function task_sigint_handler() {
|
||||||
Debug::log("[TASK] SIG_INT received.\n");
|
Debug::log("[TASK] SIG_INT received, shutting down task.");
|
||||||
task_shutdown();
|
task_shutdown();
|
||||||
die;
|
die;
|
||||||
}
|
}
|
||||||
|
@ -215,7 +215,7 @@
|
||||||
|
|
||||||
if ($next_spawn % 60 == 0) {
|
if ($next_spawn % 60 == 0) {
|
||||||
$running_jobs = count($children);
|
$running_jobs = count($children);
|
||||||
Debug::log("[MASTER] active jobs: $running_jobs, next spawn at $next_spawn sec.");
|
Debug::log("$running_jobs active tasks, next spawn at $next_spawn sec.");
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($last_checkpoint + $spawn_interval < time()) {
|
if ($last_checkpoint + $spawn_interval < time()) {
|
||||||
|
@ -229,14 +229,14 @@
|
||||||
} else if ($pid) {
|
} else if ($pid) {
|
||||||
|
|
||||||
if (!$master_handlers_installed) {
|
if (!$master_handlers_installed) {
|
||||||
Debug::log("[MASTER] installing shutdown handlers");
|
Debug::log("Installing shutdown handlers");
|
||||||
pcntl_signal(SIGINT, 'sigint_handler');
|
pcntl_signal(SIGINT, 'sigint_handler');
|
||||||
pcntl_signal(SIGTERM, 'sigint_handler');
|
pcntl_signal(SIGTERM, 'sigint_handler');
|
||||||
register_shutdown_function('shutdown', posix_getpid());
|
register_shutdown_function('shutdown', posix_getpid());
|
||||||
$master_handlers_installed = true;
|
$master_handlers_installed = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
Debug::log("[MASTER] spawned client $j [PID:$pid]...");
|
Debug::log("Spawned child process with PID $pid for task $j.");
|
||||||
array_push($children, $pid);
|
array_push($children, $pid);
|
||||||
$ctimes[$pid] = time();
|
$ctimes[$pid] = time();
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in New Issue