I have a Ubuntu 12.04 machine in which I am running my C++ app server which I am controlling through upstart script. Meaning whenever my app server crashes my upstart script will restart them back automatically and whenever my ubuntu machine gets rebooted/restarted my upstart script will restart my app server again.
Below is my upstart script:
start on runlevel  stop on runlevel  chdir /opt/process/process_server respawn post-start script echo "App server started at `date +"%F %T"` on `hostname -f`" | mailx -r "firstname.lastname@example.org" -s "Process Started" "email@example.com" end script post-stop script sleep 30 end script limit core unlimited unlimited limit nofile 8092 8092 setuid caprti exec ./process_server --config_file=../config/process.init
Now weird thing is, I have see this atleast twice - My ubuntu machine was restarted and I don't know how and who did that but my app server was not restarted at all and I don't know why? I have tested this multiple times by myself rebooting that same box by typing
"sudo reboot" and whenever that machine comes back up, I see my app server gets restarted automatically.
Under what condition during reboot of my Ubuntu box will not result in my app server getting restarted from my above upstart script? Is there anything I am missing in my Upstart script?
Also how do I verify that my Upstart script tried to restart my app server during the last reboot but it failed for some reason if that's what has happened with my for those two times?