Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add logrotate #14

Merged
merged 1 commit into from
Sep 3, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions docker/scripts/enterpoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,11 @@ if [[ -f /shared/ssl/renew_cert ]]; then
fi


# logrotate
chmod 0644 /scripts/logrotate-conf/logrotate-cron
/usr/bin/crontab /scripts/logrotate-conf/logrotate-cron


# autorun
echo
echo "Starting SeaTable Thumbnail"
Expand Down
3 changes: 3 additions & 0 deletions docker/scripts/logrotate-conf/logrotate-cron
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@

54 23 * * * /usr/sbin/logrotate -vf /scripts/logrotate-conf/seatable-nginx 2>> /opt/seatable-thumbnail/logs/logrotate.log
55 23 * * * /usr/sbin/logrotate -vf /scripts/logrotate-conf/seatable-thumbnail 2>> /opt/seatable-thumbnail/logs/logrotate.log
17 changes: 17 additions & 0 deletions docker/scripts/logrotate-conf/seatable-nginx
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/opt/nginx-logs/*.log {
daily
missingok
rotate 7
# compress
# delaycompress
dateext
dateformat .%Y-%m-%d
notifempty
# create 640 nginx adm
sharedscripts
postrotate
if [ -f /var/run/nginx.pid ]; then
kill -USR1 `cat /var/run/nginx.pid`
fi
endscript
}
17 changes: 17 additions & 0 deletions docker/scripts/logrotate-conf/seatable-thumbnail
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/opt/seatable-thumbnail/logs/seafile.log
/opt/seatable-thumbnail/logs/seatable-thumbnail.log
{
daily
missingok
rotate 7
# compress
# delaycompress
dateext
dateformat .%Y-%m-%d
notifempty
create 644 root root
sharedscripts
postrotate
/scripts/logrotate-conf/seatable-thumbnail-restart.sh
endscript
}
53 changes: 53 additions & 0 deletions docker/scripts/logrotate-conf/seatable-thumbnail-restart.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
#!/bin/bash

function stop_server() {
pkill -9 -f seaf-server
pkill -9 -f uvicorn
pkill -9 -f multiprocessing

rm -f /opt/seatable-thumbnail/pids/*.pid
}

function set_env() {
export SRC_DIR=/opt/seatable-thumbnail/
export LD_LIBRARY_PATH=/opt/seatable-thumbnail/seafile/lib/
export PYTHONPATH=/opt/seatable-thumbnail/seafile/lib/python3.6/site-packages/:/usr/lib/python3.6/dist-packages:/usr/lib/python3.6/site-packages:/usr/local/lib/python3.6/dist-packages:/usr/local/lib/python3.6/site-packages
export PATH=/opt/seatable-thumbnail/seafile/bin/:$PATH

export CCNET_CONF_DIR=/opt/seatable-thumbnail/ccnet
export SEAFILE_CONF_DIR=/opt/seatable-thumbnail/seafile-data
export SEAFILE_CENTRAL_CONF_DIR=/opt/seatable-thumbnail/conf
}


function start_server() {

stop_server
sleep 0.5

set_env

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 - &
sleep 0.2

cd /opt/seatable-thumbnail/seatable-thumbnail-server/
/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 &
sleep 0.2

echo "SeaTable-thumbnail-server started by logrotate"
echo

}


case $1 in
"start")
start_server
;;
"stop")
stop_server
;;
*)
start_server
;;
esac
2 changes: 1 addition & 1 deletion docker/scripts/monitor.sh
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ function monitor_seatable_thumbnail() {
pkill -9 -f multiprocessing
sleep 0.2
cd /opt/seatable-thumbnail/seatable-thumbnail-server/
uvicorn main:app --host 127.0.0.1 --port 8088 --workers 4 --access-log --proxy-headers &>> /opt/seatable-thumbnail/logs/seatable-thumbnail.log &
/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 &
sleep 0.2
fi
}
Expand Down
2 changes: 1 addition & 1 deletion docker/scripts/seatable-thumbnail.sh
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ function start_server() {
sleep 0.2

cd /opt/seatable-thumbnail/seatable-thumbnail-server/
uvicorn main:app --host 127.0.0.1 --port 8088 --workers 4 --access-log --proxy-headers &>> /opt/seatable-thumbnail/logs/seatable-thumbnail.log &
/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 &
sleep 0.2

/scripts/monitor.sh &>> /opt/seatable-thumbnail/logs/monitor.log &
Expand Down