Restart service or even reboot upon service stopping
The following service startups upon reboot. I don't have remote access to the machine, and wish to restart it even if something goes wrong and the service halts. How can I restart it so? What about rebooting the machine if it halts? Thanks
Code:
#!/bin/sh |
init 6
|
Quote:
|
It depends on the distribution/version and init system.
With systemd you can use the restart option in the unit configuration file. https://www.freedesktop.org/software...d.service.html In upstart you can use the respawn in the service's configuration file With SysV you can use /etc/inittab Not exactly sure if using a LSB script in systemd Rebooting the computer if the OS crashes is typically done using a watchdog timer not normally found on home desktop computers. You would need something like an IPMI card. https://en.wikipedia.org/wiki/Intell...ment_Interface |
Quote:
|
Depends on distribution/version installed. If using raspbian jessie then it is running systemd.
While systemd supports LSB scripts I'm not sure at the moment what to configure to make it restart automatically. If your Pi is running a systemd distribution you might want to consider writing a systemd unit file. The Pi does have a built in watchdog timer but have not tried using it. I found one link that claims the builtin timer was unreliable and an external one was added. Maybe others will chime in that have actually tried to use it. http://www.raspberry-pi-geek.com/Arc...-more-reliable https://www.element14.com/community/...e-raspberry-pi |
D. J. Bernstein's daemontools will do exactly what you're asking. It starts a daemon on boot, and will restart it if it halts or fails. http://cr.yp.to/daemontools.html.
|
Quote:
The link described using an daemon to pat the internal watchdog. The daemon is independent of my service, so the service can choke but the machine will be fine. So, the watchdog protects against system failure and not just the process choking, right? But then the link described using "the following code" to pat the external watchdog. If this code is in the application, then this implementation is really to prevent the service from not operating correctly. Am I interpreting this correctly? Thanks |
Something needs to reset the watchdog timer. If a separate process then the watchdog just protects against system failure. If the reset is accomplished by your process then it protects both. If using a daemon watchdog then you still need another watchdog to monitor your process.
|
Quote:
|
Not that I know.
|
All times are GMT -5. The time now is 07:25 AM. |