正在显示
4 个修改的文件
包含
110 行增加
和
0 行删除
rollback.sh
0 → 100755
1 | +#!/bin/bash | ||
2 | + | ||
3 | +pwd=`pwd` | ||
4 | +target=`basename $pwd` | ||
5 | + | ||
6 | +# Kill running program | ||
7 | +pid=`ps -C ${target} -o pid=` | ||
8 | +if [ -n "$pid" ]; then | ||
9 | + | ||
10 | + echo "Stopping old version, PID: ${pid}" | ||
11 | + if [ "$1" = "-f" ]; then | ||
12 | + # force shutdown | ||
13 | + echo "Force shutdown..." | ||
14 | + kill $(ps -C ${target} -o pid=) | ||
15 | + else | ||
16 | + kill -s 2 $(ps -C ${target} -o pid=) | ||
17 | + fi | ||
18 | + | ||
19 | + # wait for program to stop | ||
20 | + pid=`ps -C ${target} -o pid=` | ||
21 | + while [ -n "$pid" ]; do | ||
22 | + sleep 1 | ||
23 | + done | ||
24 | +fi | ||
25 | + | ||
26 | +# Rollback | ||
27 | +if [ -f "${target}-backup" ]; then | ||
28 | + echo "Rolling back..." | ||
29 | + if [ -f "${target}" ]; then | ||
30 | + rm "${target}" | ||
31 | + fi | ||
32 | + mv ${target}-backup ${target} | ||
33 | + echo "Rollback Complete" | ||
34 | +fi | ||
35 | + | ||
36 | +# run | ||
37 | +echo "Starting..." | ||
38 | +./run.sh ${target} | ||
39 | +echo "Done" |
start.sh
0 → 100755
1 | +#!/bin/bash | ||
2 | + | ||
3 | +pwd=`pwd` | ||
4 | +target=`basename $pwd` | ||
5 | +# kill | ||
6 | +pid=`ps -C ${target} -o pid=` | ||
7 | +if [ -n "$pid" ]; then | ||
8 | + echo "Stopping old version, PID: ${pid}" | ||
9 | + if [ "$1" = "-f" ]; then | ||
10 | + # force shutdown | ||
11 | + echo "Force shutdown..." | ||
12 | + kill -9 $(ps -C ${target} -o pid=) | ||
13 | + else | ||
14 | + kill -9 $(ps -C ${target} -o pid=) | ||
15 | + fi | ||
16 | + # wait for program to stop | ||
17 | + pid=`ps -C ${target} -o pid=` | ||
18 | + while [ -n "$pid" ]; do | ||
19 | + sleep 1 | ||
20 | + done | ||
21 | +fi | ||
22 | + | ||
23 | +# upgrade | ||
24 | +if [ -f "${target}-new" ]; then | ||
25 | + echo "Upgrading..." | ||
26 | + if [ -f "${target}-backup" ]; then | ||
27 | + backupdt=`date +%Y%m%d-%H` | ||
28 | + mv "${target}-backup" "${target}-backup-${backupdt}" | ||
29 | + fi | ||
30 | + | ||
31 | + mv ${target} ${target}-backup | ||
32 | + mv ${target}-new ${target} | ||
33 | + | ||
34 | + echo "Upgrade Complete" | ||
35 | +fi | ||
36 | + | ||
37 | +# run | ||
38 | +echo "Starting..." | ||
39 | +./run.sh ${target} | ||
40 | +echo "Done" |
stop.sh
0 → 100755
1 | +#!/bin/bash | ||
2 | + | ||
3 | +pwd=`pwd` | ||
4 | +target=`basename $pwd` | ||
5 | + | ||
6 | +# kill | ||
7 | +pid=`ps -C ${target} -o pid=` | ||
8 | +if [ -n "$pid" ]; then | ||
9 | + | ||
10 | + echo "Stopping old version, PID: ${pid}" | ||
11 | + if [ "$1" = "-f" ]; then | ||
12 | + # force shutdown | ||
13 | + echo "Force shutdown..." | ||
14 | + kill -9 $(ps -C ${target} -o pid=) | ||
15 | + else | ||
16 | + kill -9 $(ps -C ${target} -o pid=) | ||
17 | + fi | ||
18 | + | ||
19 | + # wait for program to stop | ||
20 | + pid=`ps -C ${target} -o pid=` | ||
21 | + while [ -n "$pid" ]; do | ||
22 | + sleep 1 | ||
23 | + done | ||
24 | + | ||
25 | +fi | ||
26 | + | ||
27 | +echo "Done" |
-
请 注册 或 登录 后发表评论