I'm going to implement a small daemon application in Java. Below is my requirement. Could someone please give me some suggestion on how to do it?
- To start and monitor another process (restart it if it is crashed)
- Run on both Windows and Linux (SUSE is preferred)
- Also the daemon app itself never exits, it should gracefully exit when receiving the OS shutdown signal.
For Windows, I can call several Win32 APIs to start Process and monitor its status. The daemon app could be a Windows service whose life-cycle is managed by Windows automatically.
Question is, how to do it against Linux. Furthermore, how to write one set of code to deal with both OSs rather than two?