add enterpoint.sh

This commit is contained in:
sniper-py 2020-07-16 15:14:10 +08:00
parent f3e0176f61
commit ce319c80ec
4 changed files with 44 additions and 4 deletions

View file

@ -68,4 +68,4 @@ RUN mkdir -p /opt/seafile/ && cd /opt/seafile/ && \
EXPOSE 80
CMD ["/sbin/my_init", "--", "bash", "-l"]
CMD ["/sbin/my_init", "--", "/scripts/enterpoint.sh"]

View file

@ -75,7 +75,7 @@ if [[ ! -e latest_version_dir ]]; then
ln -sf $current_version_dir $latest_version_dir
fi
chmod u+x /scripts/*
# chmod u+x /scripts/*
echo $PYTHON
$PYTHON /scripts/init.py
# echo $PYTHON
# $PYTHON /scripts/init.py

View file

@ -0,0 +1,37 @@
#!/bin/bash
# log function
function log() {
local time=$(date +"%F %T")
echo "$time $1 "
echo "[$time] $1 " &>> /opt/seafile/logs/enterpoint.log
}
# check nginx
while [ 1 ]; do
process_num=$(ps -ef | grep "/usr/sbin/nginx" | grep -v "grep" | wc -l)
if [ $process_num -eq 0 ]; then
log "Waiting Nginx"
sleep 0.2
else
log "Nginx ready"
break
fi
done
log "This is a idle script (infinite loop) to keep container running."
function cleanup() {
kill -s SIGTERM $!
exit 0
}
trap cleanup SIGINT SIGTERM
while [ 1 ]; do
sleep 60 &
wait $!
done

View file

@ -40,7 +40,10 @@ def main():
generate_local_nginx_conf()
if not exists(join(shared_seafiledir, 'conf')):
print('Start init')
init_seafile_server()
else:
print('Conf exists')
if __name__ == '__main__':
main()