-
Notifications
You must be signed in to change notification settings - Fork 1
/
install.sh
executable file
·50 lines (44 loc) · 1.27 KB
/
install.sh
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
#!/bin/sh
set -eu
systemctl | grep -q "${PROJECT_NAME}.service" && systemctl stop ${PROJECT_NAME}.service
[ -f "${API_SOCKET}" ] && chown ${API_USER}:${API_GROUP} "${API_SOCKET}"
# Generate systemd unit file
cat <<EOF > "/etc/systemd/system/${PROJECT_NAME}.service"
# This file is automatically generated, do not alter
[Unit]
Description=API daemon for ${PROJECT_NAME}
After=network.target
[Service]
ExecStart="${PROJECT_PATH}/server/bin/uwsgi" \
--master \
--processes=${API_UWSGI_PROCESSES} \
--threads=${API_UWSGI_THREADS} \
--enable-threads --thunder-lock \
--mount /=${EGG_NAME}.uwsgi:app \
--need-app \
--chmod-socket=666 \
--harakiri ${API_UWSGI_HARAKIRI} \
-s ${API_SOCKET}
WorkingDirectory=${PROJECT_PATH}/server
DynamicUser=yes
RuntimeDirectory=${PROJECT_NAME}
User=${API_USER}
Group=${API_GROUP}
Restart=on-failure
RestartSec=5s
KillSignal=SIGQUIT
Type=notify
StandardError=syslog
NotifyAccess=all
[Install]
WantedBy=multi-user.target
EOF
# Make sure server is started / stopped as expected
systemctl daemon-reload
if [ "${PROJECT_MODE}" = "production" ]; then
systemctl enable ${PROJECT_NAME}.service
systemctl start ${PROJECT_NAME}.service
else
systemctl disable ${PROJECT_NAME}.service
systemctl stop ${PROJECT_NAME}.service
fi