mirror of
https://github.com/friendica/friendica
synced 2024-12-22 22:00:16 +00:00
Dead processes will be deleted when they are running for more than 9 minutes.
This commit is contained in:
parent
58cea13707
commit
e32f9c4fff
5 changed files with 31 additions and 8 deletions
|
@ -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');
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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));
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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…
Reference in a new issue