aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
-rwxr-xr-xbackup-sims.sh16
-rwxr-xr-xcreate_region.sh3
-rw-r--r--opensim-crontab.txt3
-rw-r--r--opensim-monit.conf8
-rwxr-xr-xstart-sim83
5 files changed, 66 insertions, 47 deletions
diff --git a/backup-sims.sh b/backup-sims.sh
new file mode 100755
index 0000000..775ebbe
--- /dev/null
+++ b/backup-sims.sh
@@ -0,0 +1,16 @@
1#!/bin/bash
2
3OSPATH="/opt/opensim"
4
5for i in $(seq 99)
6do
7 j=$(printf "sim%02d" $i)
8 if [ -e "$OSPATH/config/$j" ]
9 then
10 cd $OSPATH/config/$j
11 ./backup-sim
12 # sleep for three minutes, so that there is plenty of time to do the backup,
13 # and we are not keeping the computer very busy if there are lots of sims.
14 sleep(180)
15 fi
16done
diff --git a/create_region.sh b/create_region.sh
index 5c27052..33257fd 100755
--- a/create_region.sh
+++ b/create_region.sh
@@ -65,6 +65,9 @@ ExternalHostName = $URL
65zzzzEOFzzzz 65zzzzEOFzzzz
66 66
67ln -s ../../setup/start-sim start-sim 67ln -s ../../setup/start-sim start-sim
68ln -s ../../setup/backup-sim start-sim
69ln -s ../../setup/sim-console start-sim
70ln -s ../../setup/stop-sim start-sim
68cp ../../current/bin/OpenSim.exe.config OpenSim.exe.config 71cp ../../current/bin/OpenSim.exe.config OpenSim.exe.config
69sed -i 's@<appender name="LogFileAppender" type="log4net.Appender.FileAppender">@<appender name="LogFileAppender" type="log4net.Appender.RollingFileAppender">@' OpenSim.exe.config 72sed -i 's@<appender name="LogFileAppender" type="log4net.Appender.FileAppender">@<appender name="LogFileAppender" type="log4net.Appender.RollingFileAppender">@' OpenSim.exe.config
70sed -i "s@<file value=\"OpenSim.log\" />@<file value=\"/var/log/opensim/sim$NUM.log\" />@" OpenSim.exe.config 73sed -i "s@<file value=\"OpenSim.log\" />@<file value=\"/var/log/opensim/sim$NUM.log\" />@" OpenSim.exe.config
diff --git a/opensim-crontab.txt b/opensim-crontab.txt
index ab694f7..caaaafc 100644
--- a/opensim-crontab.txt
+++ b/opensim-crontab.txt
@@ -9,3 +9,6 @@
9# experimental version using savelog -c cycles all opensim log files over 7 days 9# experimental version using savelog -c cycles all opensim log files over 7 days
100 0 * * * /usr/bin/savelog -c 7 /var/log/opensim/*.log 100 0 * * * /usr/bin/savelog -c 7 /var/log/opensim/*.log
11 11
12# Backup the sims every 6 hours.
130 */6 * * * /opt/opensim/setup/backup-sims.sh
14
diff --git a/opensim-monit.conf b/opensim-monit.conf
index c98ad91..7d26a82 100644
--- a/opensim-monit.conf
+++ b/opensim-monit.conf
@@ -20,11 +20,11 @@
20# see ../README for configuration instructions. 20# see ../README for configuration instructions.
21# 21#
22check process sim01 with pidfile /var/run/opensim/sim01.pid 22check process sim01 with pidfile /var/run/opensim/sim01.pid
23 start program = "/bin/bash -c 'cd /opt/opensim/config/sim01 && /opt/opensim/sim01/start-sim -q'" 23 start program = "/bin/bash -c 'cd /opt/opensim/config/sim01 && /opt/opensim/config/sim01/start-sim -q'"
24 as uid opensim and gid opensim 24 as uid opensim and gid opensim
25 stop program = "/bin/kill -9 `cat /var/run/opensim/sim01.pid`" 25 stop program = "/bin/bash -c 'cd /opt/opensim/config/sim01 && /opt/opensim/config/sim01/stop-sim'" with timeout 600 seconds
26# if cpu usage > 300% for 4 cycles then restart 26 if cpu usage > 200% for 4 cycles then restart
27# if 5 restarts within 5 cycles then timeout 27 if 5 restarts within 5 cycles then timeout
28# if failed url http://127.0.0.1:9005/jsonSimStats/ 28# if failed url http://127.0.0.1:9005/jsonSimStats/
29# and content != '"SimFPS":0.0,' for 4 cycles 29# and content != '"SimFPS":0.0,' for 4 cycles
30# then restart 30# then restart
diff --git a/start-sim b/start-sim
index dbb1beb..ea77553 100755
--- a/start-sim
+++ b/start-sim
@@ -1,12 +1,5 @@
1#!/bin/bash 1#!/bin/bash
2 2
3# Pick one of these depending on how you want your access.
4# NOTE - REST does not work. B-(
5#NeedARest=" -console=rest"
6NeedARest=""
7Screaming="true"
8#Screaming=""
9
10USER=$(whoami) 3USER=$(whoami)
11console_name="OpenSim_console" 4console_name="OpenSim_console"
12screen_session=opensim/${console_name} 5screen_session=opensim/${console_name}
@@ -32,7 +25,7 @@ fi
32 25
33if [ "x$tgt" = "x" ]; then 26if [ "x$tgt" = "x" ]; then
34 echo "usage:" 27 echo "usage:"
35 echo " $ start-sim-in-rest <sim>" 28 echo " $ $(basename $0) <sim>"
36 echo "where <sim> is one of: " robust sim[0-9][0-9] 29 echo "where <sim> is one of: " robust sim[0-9][0-9]
37 exit 1 30 exit 1
38fi 31fi
@@ -49,15 +42,10 @@ export MONO_PATH=${bindir}
49# Then we would not have to do this, and subsequently write all over the damn bin directory. 42# Then we would not have to do this, and subsequently write all over the damn bin directory.
50cd ${bindir} 43cd ${bindir}
51 44
52if [ "x$Screaming" = "xtrue" ] 45if ($screen_check | grep -q ${console_name}); then
53then 46 true
54 if ($screen_check | grep -q ${console_name}); then 47else
55 echo "INFO: Screen already running" 48 $SUDO screen -d -m -S ${console_name}
56 true
57 else
58 echo "DEBUG: Starting screen"
59 $SUDO screen -d -m -S ${console_name}
60 fi
61fi 49fi
62 50
63if [ "x$tgt" = "xrobust" ]; then 51if [ "x$tgt" = "xrobust" ]; then
@@ -67,33 +55,42 @@ else
67fi 55fi
68 56
69inidir=/opt/opensim/config/${tgt} 57inidir=/opt/opensim/config/${tgt}
70cmd="/usr/bin/mono ${bindir}/${exe}.exe -inidirectory=${inidir} -logconfig=${inidir}/${exe}.exe.config $NeedARest" 58# Grab the first line of the sim.ini file, it should be the sim name in square brackets.
71title=$(head -n 1 ${inidir}/Regions/sim.ini ) 59title=$(head -n 1 ${inidir}/Regions/sim.ini )
60# Strip off spaces at either end.
61shopt -s extglob
62title=${title##*( )}
63title=${title%%*( )}
64shopt -u extglob
65# Strip off the square brackets at either end.
66title=${title:1:$(( ${#title} - 2 ))}
72 67
73# Check if it's already running. 68case $(basename $0) in
74if [ ! -e /var/run/opensim/${tgt}.pid ] 69 "start-sim")
75then 70 cmd="/usr/bin/mono ${bindir}/${exe}.exe -inidirectory=${inidir} -logconfig=${inidir}/${exe}.exe.config"
76 if [ "x$Screaming" = "xtrue" ]
77 then
78 echo "INFO: start process and connect to screen (opensim) $title"
79 $SUDO screen -r ${screen_session} -p "-" -X screen -t "${title}" ${cmd}
80 else
81 $cmd
82 fi
83fi
84 71
85if [ "x$quiet" = "x" ] 72 # Check if it's already running.
86then 73 if [ ! -e /var/run/opensim/${tgt}.pid ]
87 # Either way, need to start up the console after. 74 then
88 if [ "x$Screaming" = "xtrue" ] 75 $SUDO screen -r ${screen_session} -p "-" -X screen -t "[${title}]" ${cmd}
89 then 76 fi
90 echo "Starting screen client." 77 ;&
91 screen -r ${screen_session} -A 78
92 elif [ "x$NeedARest" != "x" ] 79 "sim-console")
93 then 80 if [ "x$quiet" = "x" ]
94 echo "Starting rest client." 81 then
95 cd ${inidir} 82 screen -r ${screen_session} -p "[${title}]" -A
96 /usr/bin/mono ${bindir}/OpenSim.ConsoleClient.exe -logconfig=${inidir}/${exe}.exe.config 83 fi
97 fi 84 ;;
98fi 85
86 "backup-sim")
87 # Substitute underscores for spaces in the title, then add the full date and time to create the OAR file name.
88 cmd="save oar ${inidir}/../../backups/${title// /_}-$(date '+%F_%T').oar"
89 sudo -Hu opensim screen -r opensim/OpenSim_console -p "[${title}]" -X stuff "${cmd}$(/bin/echo -ne '\015')"
90 ;;
91
92 "stop-sim")
93 sudo -Hu opensim screen -r opensim/OpenSim_console -p "[${title}]" -X stuff "shutdown$(/bin/echo -ne '\015')"
94 ;;
95esac
99 96