-
Notifications
You must be signed in to change notification settings - Fork 2
/
upgrade-amusewiki.muse
116 lines (93 loc) · 2.8 KB
/
upgrade-amusewiki.muse
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
#pubdate 2017-06-15 12:27:43 +0200
#title Upgrading
#author Marco Pessotto
#lang en
#topics doc, howto
#teaser How to upgrade Amusewiki without downtime
The upgrade procedure depends on the way you installed amusewiki.
*** Debian package
The recommended way is to install the application from the debian
packages. That way the upgrade is automatically managed by the
package, with zero downtime.
Please note that if you are using mysql or postgresql, and the
database is currently being restarted by the upgrade procedure, you
will get a failure during the amusewiki upgrade. This is nothing to be
scared. Just run =apt-get upgrade= again and it will be fixed (again,
without the application going down).
*** Running in tree with the init script
If you installed from git and are running the app in the tree:
{{{
./init-all.sh stop
git pull
./init-all.sh start
}}}
DB upgrades are managed automatically. If some manual operation is
required, it will be listed in the Changes file.
This is the suggested script to do a 0-downtime upgrade. We don't ship
it in the distribution because it looks fragile to run a shell script
which potentially could change itself.
{{{
#!/bin/sh
set -e
./script/amusewikifarm_fastcgi.pl -l var/amw.sock -n 3 2>/dev/null >/dev/null &
temp_pid=$!
echo "Started copy of the application with pid $temp_pid. If this script exits prematurely, please kill it yourself"
echo "Waiting for the backup app to come up"
sleep 20
echo "Stopping the app"
./init-all.sh stop
git pull
echo "Starting the app"
./init-all.sh start
echo "Waiting for the new app to come up"
sleep 20
# kill the old
echo "Stopping the backup app $temp_pid"
kill $temp_pid
echo "All done, no errors"
}}}
*** Running in tree, but started with systemd and selinux
You could install this script and use it to perform the upgrades (or
do manually with the same logic). Run it as root.
{{{
#!/bin/sh
set -e
amusewiki=/var/www/amusewiki/amusewiki
if [ "x$1" != "x" ]; then
amusewiki=$1
fi
if [ -f "$amusewiki/lib/AmuseWikiFarm.pm" ]; then
owner=`ls -ld "$amusewiki/lib/AmuseWikiFarm.pm" | awk '{print $3}'`;
else
echo "$amusewiki is not a directory"
exit 2
fi
if [ "$owner" = "root" ]; then
echo "Owner of amusewiki shouldn't be root";
exit 2;
fi
if [ "x$owner" = "x" ]; then
echo "Amusewiki owner not found!"
exit 2
fi
if id $owner > /dev/null; then
echo "Upgrading $amusewiki owned by $owner"
sleep 2
else
echo "$owner not found"
exit 2
fi
systemctl stop amusewiki-jobber
su -c "cd $amusewiki; git pull; ./init-all.sh start-app" -l $owner
sleep 10;
systemctl restart amusewiki-web
sleep 10;
su -c "cd $amusewiki; ./init-all.sh stop-app" -l $owner
sleep 10;
systemctl start amusewiki-jobber
systemctl restart amusewiki-cgit
sleep 10;
# check if everything is fine
systemctl status 'amusewiki-*'
ps -u $owner f
}}}