Browse Source

Dead processes will be deleted when they are running for more than 9 minutes.

pull/987/head
Michael Vogel 6 years ago
parent
commit
e32f9c4fff
5 changed files with 31 additions and 8 deletions
  1. +7
    -3
      include/cronhooks.php
  2. +1
    -1
      include/onepoll.php
  3. +9
    -0
      include/pidfile.php
  4. +7
    -1
      include/poller.php
  5. +7
    -3
      include/queue.php

+ 7
- 3
include/cronhooks.php View File

@ -37,9 +37,15 @@ function cronhooks_run(&$argv, &$argc){
$lockpath = get_config('system','lockpath');
if ($lockpath != '') {
$pidfile = new pidfile($lockpath, 'cron.lck');
$pidfile = new pidfile($lockpath, 'cronhooks');
if($pidfile->is_already_running()) {
logger("cronhooks: Already running");
if ($pidfile->running_time() > 9*60) {
$pidfile->kill();
logger("cronhooks: killed stale process");
// Calling a new instance
proc_run('php','include/cronhooks.php');
}
exit;
}
}
@ -52,8 +58,6 @@ function cronhooks_run(&$argv, &$argc){
$d = datetime_convert();
set_time_limit(9*60*60); // Setting the maximum execution time for cronjobs to 9 minutes.
call_hooks('cron', $d);
logger('cronhooks: end');


+ 1
- 1
include/onepoll.php View File

@ -60,7 +60,7 @@ function onepoll_run(&$argv, &$argc){
// Test
$lockpath = get_config('system','lockpath');
if ($lockpath != '') {
$pidfile = new pidfile($lockpath, 'onepoll'.$contact_id.'.lck');
$pidfile = new pidfile($lockpath, 'onepoll'.$contact_id);
if($pidfile->is_already_running()) {
logger("onepoll: Already running for contact ".$contact_id);
exit;


+ 9
- 0
include/pidfile.php View File

@ -28,5 +28,14 @@ class pidfile {
public function is_already_running() {
return $this->_running;
}
public function running_time() {
return(time() - filectime($this->_file));
}
public function kill() {
if (file_exists($this->_file))
return(posix_kill(file_get_contents($this->_file), SIGTERM));
}
}
?>

+ 7
- 1
include/poller.php View File

@ -43,9 +43,15 @@ function poller_run(&$argv, &$argc){
$lockpath = get_config('system','lockpath');
if ($lockpath != '') {
$pidfile = new pidfile($lockpath, 'poller.lck');
$pidfile = new pidfile($lockpath, 'poller');
if($pidfile->is_already_running()) {
logger("poller: Already running");
if ($pidfile->running_time() > 9*60) {
$pidfile->kill();
logger("poller: killed stale process");
// Calling a new instance
proc_run('php','include/poller.php');
}
exit;
}
}


+ 7
- 3
include/queue.php View File

@ -86,9 +86,15 @@ function queue_run(&$argv, &$argc){
$lockpath = get_config('system','lockpath');
if ($lockpath != '') {
$pidfile = new pidfile($lockpath, 'queue.lck');
$pidfile = new pidfile($lockpath, 'queue');
if($pidfile->is_already_running()) {
logger("queue: Already running");
if ($pidfile->running_time() > 9*60) {
$pidfile->kill();
logger("queue: killed stale process");
// Calling a new instance
proc_run('php',"include/queue.php");
}
return;
}
}
@ -106,8 +112,6 @@ function queue_run(&$argv, &$argc){
logger('queue: start');
set_time_limit(9*60*60); // Setting the maximum execution time for queue job to 9 minutes.
handle_pubsubhubbub();
$interval = ((get_config('system','delivery_interval') === false) ? 2 : intval(get_config('system','delivery_interval')));


Loading…
Cancel
Save