mirror of
https://github.com/RaspbianFrance/raspisms.git
synced 2025-07-21 20:38:46 +02:00
Better handling of raspisms service restart after exception in daemons, and add 5 seconds delay between restart retries
This commit is contained in:
parent
aaa0fe5701
commit
1f8cdcd67c
3 changed files with 7 additions and 1 deletions
|
@ -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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue