-
Notifications
You must be signed in to change notification settings - Fork 0
/
start.sh
executable file
·58 lines (42 loc) · 1.07 KB
/
start.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
51
52
53
54
55
56
57
58
#!/bin/bash
set +e
VERSION="${PHP_VERSION:-8.2}"
ENABLE_COMMIT_CRON=false
SCRIPT=$(realpath "$0")
SCRIPTPATH=$(dirname "$SCRIPT")
mkdir -p /tmp/log
mkdir -p /tmp/run
PHP_PID_FILE="/tmp/run/php-fpm.pid"
COMMIT_PID_FILE="/tmp/run/commit.pid"
export PHPRC=$SCRIPTPATH/php
function stop_php() {
if [ -f "$PHP_PID_FILE" ]; then
kill "$(cat $PHP_PID_FILE)"
rm $PHP_PID_FILE
fi
}
function stop_commit_cron() {
if [ -f "$COMMIT_PID_FILE" ]; then
kill "$(cat $COMMIT_PID_FILE)"
rm $COMMIT_PID_FILE
fi
}
function start_commit_cron() {
echo "Start Commit Cron Service"
sudo -u admin n install 16.13.2
$SCRIPTPATH/.backup/cron-commit.js --schedule "0 */4 * * * *" &
COMMIT_CRON_PID=$!
echo $COMMIT_CRON_PID > /tmp/run/cron.pid
}
stop_php
stop_commit_cron
echo "Start PHP FPM Service"
php-fpm${VERSION} -y $SCRIPTPATH/php/php-fpm.conf
trap stop_php EXIT
if $ENABLE_COMMIT_CRON
then
start_commit_cron
trap stop_commit_cron EXIT
fi
echo "Start nginx on port 3000"
nginx -c $SCRIPTPATH/nginx/nginx.conf -g 'daemon off;'