diff options
author | David Walter Seikel | 2011-11-28 04:53:09 +1000 |
---|---|---|
committer | David Walter Seikel | 2011-11-28 04:53:09 +1000 |
commit | 554583496a2fdd3b9399c73a7fc526f99956e5bc (patch) | |
tree | ac2bb5d813f39b239179560855a15eceb4cf8682 | |
parent | No need to deal with ownership and perms, the install script does that now. (diff) | |
download | IGnoble-554583496a2fdd3b9399c73a7fc526f99956e5bc.zip IGnoble-554583496a2fdd3b9399c73a7fc526f99956e5bc.tar.gz IGnoble-554583496a2fdd3b9399c73a7fc526f99956e5bc.tar.bz2 IGnoble-554583496a2fdd3b9399c73a7fc526f99956e5bc.tar.xz |
Backup sim regularly.
Rest don't work, screen would be better even if it did work.
New scripts for stopping the sim, backing up the sim, and showing the console.
Monit script works now.
Diffstat (limited to '')
-rwxr-xr-x | backup-sims.sh | 16 | ||||
-rwxr-xr-x | create_region.sh | 3 | ||||
-rw-r--r-- | opensim-crontab.txt | 3 | ||||
-rw-r--r-- | opensim-monit.conf | 8 | ||||
-rwxr-xr-x | start-sim | 83 |
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 | |||
3 | OSPATH="/opt/opensim" | ||
4 | |||
5 | for i in $(seq 99) | ||
6 | do | ||
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 | ||
16 | done | ||
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 | |||
65 | zzzzEOFzzzz | 65 | zzzzEOFzzzz |
66 | 66 | ||
67 | ln -s ../../setup/start-sim start-sim | 67 | ln -s ../../setup/start-sim start-sim |
68 | ln -s ../../setup/backup-sim start-sim | ||
69 | ln -s ../../setup/sim-console start-sim | ||
70 | ln -s ../../setup/stop-sim start-sim | ||
68 | cp ../../current/bin/OpenSim.exe.config OpenSim.exe.config | 71 | cp ../../current/bin/OpenSim.exe.config OpenSim.exe.config |
69 | sed -i 's@<appender name="LogFileAppender" type="log4net.Appender.FileAppender">@<appender name="LogFileAppender" type="log4net.Appender.RollingFileAppender">@' OpenSim.exe.config | 72 | sed -i 's@<appender name="LogFileAppender" type="log4net.Appender.FileAppender">@<appender name="LogFileAppender" type="log4net.Appender.RollingFileAppender">@' OpenSim.exe.config |
70 | sed -i "s@<file value=\"OpenSim.log\" />@<file value=\"/var/log/opensim/sim$NUM.log\" />@" OpenSim.exe.config | 73 | sed -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 |
10 | 0 0 * * * /usr/bin/savelog -c 7 /var/log/opensim/*.log | 10 | 0 0 * * * /usr/bin/savelog -c 7 /var/log/opensim/*.log |
11 | 11 | ||
12 | # Backup the sims every 6 hours. | ||
13 | 0 */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 | # |
22 | check process sim01 with pidfile /var/run/opensim/sim01.pid | 22 | check 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 |
@@ -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" | ||
6 | NeedARest="" | ||
7 | Screaming="true" | ||
8 | #Screaming="" | ||
9 | |||
10 | USER=$(whoami) | 3 | USER=$(whoami) |
11 | console_name="OpenSim_console" | 4 | console_name="OpenSim_console" |
12 | screen_session=opensim/${console_name} | 5 | screen_session=opensim/${console_name} |
@@ -32,7 +25,7 @@ fi | |||
32 | 25 | ||
33 | if [ "x$tgt" = "x" ]; then | 26 | if [ "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 |
38 | fi | 31 | fi |
@@ -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. |
50 | cd ${bindir} | 43 | cd ${bindir} |
51 | 44 | ||
52 | if [ "x$Screaming" = "xtrue" ] | 45 | if ($screen_check | grep -q ${console_name}); then |
53 | then | 46 | true |
54 | if ($screen_check | grep -q ${console_name}); then | 47 | else |
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 | ||
61 | fi | 49 | fi |
62 | 50 | ||
63 | if [ "x$tgt" = "xrobust" ]; then | 51 | if [ "x$tgt" = "xrobust" ]; then |
@@ -67,33 +55,42 @@ else | |||
67 | fi | 55 | fi |
68 | 56 | ||
69 | inidir=/opt/opensim/config/${tgt} | 57 | inidir=/opt/opensim/config/${tgt} |
70 | cmd="/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. |
71 | title=$(head -n 1 ${inidir}/Regions/sim.ini ) | 59 | title=$(head -n 1 ${inidir}/Regions/sim.ini ) |
60 | # Strip off spaces at either end. | ||
61 | shopt -s extglob | ||
62 | title=${title##*( )} | ||
63 | title=${title%%*( )} | ||
64 | shopt -u extglob | ||
65 | # Strip off the square brackets at either end. | ||
66 | title=${title:1:$(( ${#title} - 2 ))} | ||
72 | 67 | ||
73 | # Check if it's already running. | 68 | case $(basename $0) in |
74 | if [ ! -e /var/run/opensim/${tgt}.pid ] | 69 | "start-sim") |
75 | then | 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 | ||
83 | fi | ||
84 | 71 | ||
85 | if [ "x$quiet" = "x" ] | 72 | # Check if it's already running. |
86 | then | 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 | ;; |
98 | fi | 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 | ;; | ||
95 | esac | ||
99 | 96 | ||