restart a webapp after system reboot


how would you setup an ubuntu server which reboots every night to restart your xojo webapps after the reboot?

I remember using /etc/rc.d to set scripts to run things at boot, but this was on FreeBSD.

I think Ubuntu uses /etc/init.d

install apache2 and cgi.

Create an script that launches your app in /etc/init.d (add all environment variables to it, also specify the shell to use at beginning with #! (ie #! /bin/sh)

Give it 755 mode

To know what run level are you running execute


Usually it will be 5 or 3

Then add a link in /etc/rcX.d/ to your script, X = run level where the script must be executed, example for run level 5 and your script in /etc/init.d/xojoapp

cd /etc/rc5.d ln -s ../init.d/xojoapp S05xojoapp

S03xojoapp can be what you choose, the contents of /etc/rcX.d are ran by alphabetical order

Or, simply add your app to the /etc/rc.local file. You do need the full path.

Consider using systemd. Understanding Systemd Units and Unit Files and How To Use Systemctl to Manage Systemd Services and Units may be helpful.

+1 for systemd. This is exactly what it is for. It makes it easy to set up the app environment, handle multiple instances, restart failed instances and gives you control over much, much more. Also easy to use, and should be built-in, you should definitely check it out.