NOTE: I am running Red Hat 6.7
I have a service that is configured with the Linux init system to start a process as a service when the machine boots. This was done by doing this one-time configuration from the command line:
ln -snf /home/me/bin/my_service /etc/init.d/my_service chkconfig --add my_service chkconfig --level 235 my_service on
When the OS reboots, the service starts as expected.
I ALSO need the service to be restarted if the service (my_service) crashes. From what I've read, all I need to do is add an entry to /etc/inittab that looks like this:
Where my_service_starter looks like:
#!/bin/bash /home/me/bin/my_service start
The my_service script looks like:
#!/bin/bash "/usr/java/bin/java" /home/me/bin/my_service.jar start
My understanding is that when the init system detects that my_service is not running, it will attempt to restart it by running "my_service_starter".
However this does not seem to be working. i.e. the service does not start when the OS reboots.
I need to understand how to tell the Linux init system to restart my service when the service crashes.