Make the start.py script run forever in foreground.

This commit is contained in:
Shuai Lin 2016-11-14 08:31:39 +08:00
parent 29bfc5385e
commit 2dc6f8d5bc
2 changed files with 18 additions and 2 deletions

View file

@ -65,7 +65,9 @@ bootstrap() {
start() {
set_volumes
docker run --rm -it --name seafile $volumes $image /scripts/start.py
docker run --rm -it --name seafile $volumes $image \
/sbin/my_init -- /scripts/start.py
# /sbin/my_init -- bash -l
}
enter() {

View file

@ -12,12 +12,24 @@ import os
from os.path import abspath, basename, exists, dirname, join, isdir
import shutil
import sys
import time
from utils import call, get_conf, get_install_dir, get_script
from utils import call, get_conf, get_install_dir, get_script, get_command_output
installdir = get_install_dir()
topdir = dirname(installdir)
def watch_controller():
maxretry = 4
retry = 0
while retry < maxretry:
controller_pid = get_command_output('ps aux | grep seafile-controller |grep -v grep || true').strip()
if not controller_pid:
retry += 1
time.sleep(2)
print 'seafile controller exited unexpectedly.'
sys.exit(1)
def main():
admin_pw = {
'email': get_conf('admin.email'),
@ -34,5 +46,7 @@ def main():
if exists(password_file):
os.unlink(password_file)
watch_controller()
if __name__ == '__main__':
main()