Autorestart With Upstart
From OpenSimulator
(New page: ==What is upstart?== From the official description: :[http://upstart.ubuntu.com/ Upstart] is an event-based replacement for the <tt>/sbin/init</tt> daemon which handles starting of tasks...) |
(→Monitoring/restarting OpenSimulator with upstart) |
||
(9 intermediate revisions by 4 users not shown) | |||
Line 1: | Line 1: | ||
− | ==What is upstart?== | + | __NOTOC__ |
+ | {{Quicklinks}} | ||
+ | |||
+ | == What is upstart? == | ||
From the official description: | From the official description: | ||
Line 8: | Line 11: | ||
− | ==Monitoring/restarting | + | == Monitoring/restarting OpenSimulator with upstart == |
− | The following assumes you're | + | 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. It also assumes Ubuntu 12.04 LTS (or derivatives, like Linux Mint 13). |
− | Create a file, <tt>/etc/ | + | Create a file, <tt>/etc/init/opensim.conf</tt> , 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, <tt>/var/run/opensim/opensim.screenrc</tt> , containing the following: | ||
+ | |||
+ | multiuser on | ||
+ | acladd <controlusers> | ||
+ | aclchg <controlusers> +rwx "#?" | ||
chdir /usr/lib/opensim/bin | chdir /usr/lib/opensim/bin | ||
− | screen -h 500 -t opensim mono OpenSim.exe - | + | screen -h 500 -t opensim mono OpenSim.exe -console=basic |
− | Then, to start or stop | + | where <controlusers> is a comma-separated list of users you want to give control of the OpenSimulator 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 OpenSimulator, just use: | ||
# start opensim | # start opensim | ||
Line 36: | Line 54: | ||
# stop opensim | # stop opensim | ||
− | If | + | If OpenSimulator dies on its own, upstart will automatically restart it unless it dies three times within 60 seconds. |
+ | |||
+ | To connect to OpenSimulator with screen, use: | ||
+ | |||
+ | # screen -r opensim/ | ||
+ | |||
+ | (or use <tt>sudo</tt>, if desired). Note that this will only work from the Unix userids you've specified in <controlusers> above. |
Latest revision as of 19:02, 26 January 2013
[edit] 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.
[edit] 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. It also assumes Ubuntu 12.04 LTS (or derivatives, like Linux Mint 13).
Create a file, /etc/init/opensim.conf , 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 -console=basic
where <controlusers> is a comma-separated list of users you want to give control of the OpenSimulator 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 OpenSimulator, 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.
To connect to OpenSimulator with screen, use:
# screen -r opensim/
(or use sudo, if desired). Note that this will only work from the Unix userids you've specified in <controlusers> above.