Skip to content

Commit 3eb6050

Browse files
authored
Merge pull request #15 from seatable/fix-logrotate
fix log rotate
2 parents 72422a1 + 580020c commit 3eb6050

File tree

6 files changed

+26
-6
lines changed

6 files changed

+26
-6
lines changed

docker/Dockerfile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ COPY scripts/my-ubuntu-source.list /etc/apt/sources.list
88
## Dev related libs
99
RUN apt-get update --fix-missing
1010

11+
# Time zone
12+
RUN export DEBIAN_FRONTEND=noninteractive && apt-get install -y tzdata
13+
1114
# Nginx
1215
RUN apt-get install -y nginx
1316

docker/docker-compose.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ services:
1717
environment:
1818
- SEATABLE_THUMBNAIL_SERVER_HOSTNAME=thumbnail.seatable.cn
1919
- SEATABLE_THUMBNAIL_SERVER_LETSENCRYPT=True
20+
- TIME_ZONE=Asia/Shanghai
2021
depends_on:
2122
- redis
2223
networks:

docker/scripts/01_init.sh

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,18 @@
22

33
set -e
44

5+
# time zone
6+
if [[ $TIME_ZONE != "" ]]; then
7+
time_zone=/usr/share/zoneinfo/$TIME_ZONE
8+
if [[ ! -e $time_zone ]]; then
9+
echo "invalid time zone"
10+
exit 1
11+
else
12+
ln -snf $time_zone /etc/localtime
13+
echo "$TIME_ZONE" > /etc/timezone
14+
fi
15+
fi
16+
517
# check folder
618
if [[ ! -e /shared ]]; then
719
echo 'do not find /shared path'

docker/scripts/enterpoint.sh

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,12 @@ fi
5353

5454

5555
# logrotate
56-
chmod 0644 /scripts/logrotate-conf/logrotate-cron
57-
/usr/bin/crontab /scripts/logrotate-conf/logrotate-cron
56+
if [[ -f /var/spool/cron/crontabs/root ]]; then
57+
cat /scripts/logrotate-conf/logrotate-cron >> /var/spool/cron/crontabs/root
58+
else
59+
chmod 0644 /scripts/logrotate-conf/logrotate-cron
60+
/usr/bin/crontab /scripts/logrotate-conf/logrotate-cron
61+
fi
5862

5963

6064
# autorun

docker/scripts/logrotate-conf/seatable-thumbnail

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@
1212
create 644 root root
1313
sharedscripts
1414
postrotate
15+
if [ -f /opt/seatable-thumbnail/pids/seafile.pid ]; then
16+
kill -USR1 `cat /opt/seatable-thumbnail/pids/seafile.pid`
17+
fi
18+
1519
/scripts/logrotate-conf/seatable-thumbnail-restart.sh
1620
endscript
1721
}

docker/scripts/logrotate-conf/seatable-thumbnail-restart.sh

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
#!/bin/bash
22

33
function stop_server() {
4-
pkill -9 -f seaf-server
54
pkill -9 -f uvicorn
65
pkill -9 -f multiprocessing
76
}
@@ -25,9 +24,6 @@ function start_server() {
2524

2625
set_env
2726

28-
seaf-server -F /opt/seatable-thumbnail/conf -c /opt/seatable-thumbnail/ccnet -d /opt/seatable-thumbnail/seafile-data -l /opt/seatable-thumbnail/logs/seafile.log -L /opt/seatable-thumbnail -P /opt/seatable-thumbnail/pids/seafile.pid - &
29-
sleep 0.2
30-
3127
cd /opt/seatable-thumbnail/seatable-thumbnail-server/
3228
/usr/local/bin/uvicorn main:app --host 127.0.0.1 --port 8088 --workers 4 --access-log --proxy-headers &>> /opt/seatable-thumbnail/logs/seatable-thumbnail.log &
3329
sleep 0.2

0 commit comments

Comments
 (0)