Autorestart With Upstart
From OpenSimulator
(Updating and expanding) |
(→Monitoring/restarting OpenSimulator with upstart: ...updated to proper upstart directory) |
||
Line 15: | Line 15: | ||
The following assumes you're running OpenSimulator within GNU screen, so one can detach and reattach to the console. But that's not required to use upstart. | The following assumes you're running OpenSimulator within GNU screen, so one can detach and reattach to the console. But that's not required to use upstart. | ||
− | Create a file, <tt>/etc/ | + | Create a file, <tt>/etc/init/opensim</tt> , containing the following: |
start on runlevel [!06] | start on runlevel [!06] |
Revision as of 18:48, 26 January 2013
What is upstart?
From the official description:
- Upstart is an event-based replacement for the /sbin/init daemon which handles starting of tasks and services during boot, stopping them during shutdown and supervising them while the system is running.
- It was originally developed for the Ubuntu distribution, but is intended to be suitable for deployment in all Linux distributions as a replacement for the venerable System-V init.
Monitoring/restarting OpenSimulator with upstart
The following assumes you're running OpenSimulator within GNU screen, so one can detach and reattach to the console. But that's not required to use upstart.
Create a file, /etc/init/opensim , containing the following:
start on runlevel [!06] stop on runlevel [06] post-stop script OSPID=`ps -ef | grep opensim | grep 'mono OpenSim.exe' | awk '{ print $2 }'` kill $OSPID end script exec /bin/su - opensim -c '/usr/bin/screen -h 0 -D -m -U -S OpenSim -c /var/run/opensim/opensim.screenrc' respawn # give up if I respawn 3 times in 60 seconds... respawn limit 3 60
If you are running MySQL, you can cause OpenSim to start after MySQL starts successfully by replacing the first two lines with:
start on started mysql stop on stopping mysql
Create a file, /var/run/opensim/opensim.screenrc , containing the following:
multiuser on acladd <controlusers> aclchg <controlusers> +rwx "#?" chdir /usr/lib/opensim/bin screen -h 500 -t opensim mono OpenSim.exe -gui=true
where <controlusers> is a comma-separated list of users you want to give control of the OpenSim console to. This is needed if you run OpenSim as a service user account you never actually log in to. Note that that account must be created with a real shell.
Then, to start or stop OpenSim, just use:
# start opensim
or:
# stop opensim
If OpenSimulator dies on its own, upstart will automatically restart it unless it dies three times within 60 seconds.