mirror of
https://github.com/RaspbianFrance/raspisms.git
synced 2025-07-19 11:28: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
|
@ -11,6 +11,7 @@ ExecStart=/usr/share/raspisms/bin/start.sh
|
|||
ExecStop=/usr/share/raspisms/bin/stop.sh
|
||||
WorkingDirectory=/usr/share/raspisms
|
||||
Restart=on-failure
|
||||
RestartSec=5
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
|
|
|
@ -18,7 +18,7 @@ use PHPMailer\PHPMailer\PHPMailer;
|
|||
use PHPMailer\PHPMailer\SMTP;
|
||||
|
||||
/**
|
||||
* Mailing class.
|
||||
* Link shortner class.
|
||||
*/
|
||||
class LinkShortener
|
||||
{
|
||||
|
|
|
@ -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