-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsite_ctl.j2
75 lines (66 loc) · 1.57 KB
/
site_ctl.j2
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
#!/bin/bash
set -e
PATH="/home/pgxn_site/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
export PERL5LIB="{{ app.deploy_dir }}/lib/perl5"
cd {{ app.deploy_dir }}
start() {
if check_running; then
echo "pgxn_site_server is already running"
return
fi
bin/pgxn_site_server \
-s Starman \
-E prod \
--workers {{ app.opt.workers }} \
--preload-app \
--max-requests {{ app.opt.maxreq }} \
--listen {{ app.opt.listen }} \
--daemonize \
--pid {{ app.opt.pid }} \
--doc-root {{ app.deploy_dir }}/www \
--error-log {{ app.opt.log }} \
--errors-to {{ app.opt.errors_to }} \
--errors-from {{ app.opt.errors_from }} \
--feedback-to {{ app.opt.feedback_to }} \
--base-url {{ app.opt.base_url }} \
--api-url {{ app.opt.api_url }} \
--private-api-url {{ app.opt.private_api_url }} \
--reverse-proxy
}
stop() {
if check_running; then
kill $(getpid)
return
fi
echo "pgxn_site_server is not running"
}
restart() {
if check_running; then
kill $(getpid)
sleep 2
else
echo "pgxn_site_server is not running; skipping stop"
fi
start
}
getpid() {
echo $(cat {{ app.opt.pid }})
}
check_running() {
[ -s {{ app.opt.pid }} ] && kill -0 $(getpid) >/dev/null 2>&1
}
case "$1" in
start)
start
;;
stop)
stop
;;
restart)
restart
;;
*)
echo $"Usage: $0 {start|stop|restart}"
exit 1
esac
exit $?