* @return void
*/
function _debug($msg, $show = true) {
+ if (defined('SUPPRESS_DEBUGGING'))
+ return false;
$ts = strftime("%H:%M:%S", time());
if (function_exists('posix_getpid')) {
$fp = fopen(LOGFILE, 'a+');
if ($fp) {
+ $locked = false;
+
+ if (function_exists("flock")) {
+ $tries = 0;
+
+ // try to lock logfile for writing
+ while ($tries < 5 && !$locked = flock($fp, LOCK_EX | LOCK_NB)) {
+ sleep(1);
+ ++$tries;
+ }
+
+ if (!$locked) {
+ fclose($fp);
+ return;
+ }
+ }
+
fputs($fp, "[$ts] $msg\n");
+
+ if (function_exists("flock")) {
+ flock($fp, LOCK_UN);
+ }
+
fclose($fp);
}
}
$debug_enabled = defined('DAEMON_EXTENDED_DEBUG') || $_REQUEST['xdebug'];
+ if (!$debug_enabled) define('SUPPRESS_DEBUGGING', true);
+
_debug("start", $debug_enabled);
$result = db_query("SELECT id,update_interval,auth_login,
register_shutdown_function('task_shutdown');
$quiet = (isset($options["quiet"])) ? "--quiet" : "";
+ $log = function_exists("flock") && isset($options['log']) ? '--log '.$options['log'] : '';
$my_pid = posix_getpid();
- passthru(PHP_EXECUTABLE . " update.php --daemon-loop $quiet --task $j --pidlock $my_pid");
+ passthru(PHP_EXECUTABLE . " update.php --daemon-loop $quiet $log --task $j --pidlock $my_pid");
sleep(1);