Skip to content

Commit

Permalink
Merge pull request #1992 from xiagw/fix-docker-stop
Browse files Browse the repository at this point in the history
fix docker stop
  • Loading branch information
star7th committed Jul 15, 2023
2 parents 0fcbbce + 0f2528f commit a084113
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 4 deletions.
14 changes: 13 additions & 1 deletion docker.build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,28 @@
set -xe

rm -rf /app
ln -s /var/www/html /app
ln -sf /var/www/html /app
## php setting
(
echo "upload_max_filesize=5120M;"
echo "post_max_size=5120M;"
) >>/opt/docker/etc/php/php.ini
echo "client_max_body_size 5120m;" >/opt/docker/etc/nginx/vhost.common.d/10-general.conf

## fix nginx warning
sed -i -e '1d' /opt/docker/etc/nginx/vhost.ssl.conf
sed -i -e '/443\ default_server/s//443\ default_server\ ssl/' /opt/docker/etc/nginx/vhost.conf

## disable service
mv /opt/docker/etc/supervisor.d/cron.conf{,.bak}
mv /opt/docker/etc/supervisor.d/dnsmasq.conf{,.bak}
# mv /opt/docker/etc/supervisor.d/nginx.conf{,.bak}
# mv /opt/docker/etc/supervisor.d/php-fpm.conf{,.bak}
mv /opt/docker/etc/supervisor.d/postfix.conf{,.bak}
mv /opt/docker/etc/supervisor.d/ssh.conf{,.bak}
mv /opt/docker/etc/supervisor.d/syslog.conf{,.bak}

## mirror in china
if [ "$IN_CHINA" = true ] && [ -f /etc/apk/repositories ]; then
sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/' /etc/apk/repositories
fi
Expand Down
25 changes: 22 additions & 3 deletions docker.run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,20 @@

set -e

## web site dir
if [ ! -f "/var/www/html/index.php" ]; then
\cp -fr /showdoc_data/html/* /var/www/html/
fi
## set file mode
chown -R 1000:1000 /var/www/html/Sqlite /var/www/html/Public/Uploads

_kill() {
echo "receive SIGTERM, kill $pids"
for pid in $pids; do
kill "$pid"
wait "$pid"
done
}

## backup sqlite file every day
db_file=/var/www/html/Sqlite/showdoc.db.php
Expand All @@ -18,18 +29,26 @@ while [ -f $db_file ]; do
fi
sleep 50
done &
pids="$pids $!"

chmod 777 -R /var/www/
(
sleep 3
cd /showdoc_data/html/server
php index.php /api/update/dockerUpdateCode
chmod 777 -R /var/www/
)
(
echo "delay 30s start mock..."
sleep 30
cd /showdoc_data/mock/
npm run start
) &
pids="$pids $!"

supervisord -c /opt/docker/etc/supervisor.conf &
pids="$pids $!"

## 识别中断信号,停止进程
trap _kill HUP INT QUIT TERM

wait

supervisord

0 comments on commit a084113

Please sign in to comment.