Better handling of raspisms service restart after exception in daemons, and add 5 seconds delay between restart retries

This commit is contained in:
osaajani 2025-07-15 23:59:12 +02:00
parent aaa0fe5701
commit 1f8cdcd67c
3 changed files with 7 additions and 1 deletions

View file

@ -153,10 +153,12 @@ abstract class AbstractDaemon
//Really start the daemon
$this->on_start();
try
{
while ($this->is_running)
{
pcntl_signal_dispatch(); //Call dispatcher for signals
$this->run();
}
@ -164,6 +166,7 @@ abstract class AbstractDaemon
catch (\Throwable $t)
{
$this->logger->critical('Exception : ' . $t->getMessage() . ' in ' . $t->getFile() . ' line ' . $t->getLine());
$exit_code = $t->getCode() ?: 1;
}
//Stop the daemon
@ -174,6 +177,8 @@ abstract class AbstractDaemon
{
unlink($this->pid_dir . '/' . $this->name . '.pid');
}
exit($exit_code ?? 0);
}
/**