diff --git a/4cat-daemon.py b/4cat-daemon.py index 7abbe6400..f9547c408 100644 --- a/4cat-daemon.py +++ b/4cat-daemon.py @@ -126,7 +126,7 @@ def start(): with daemon.DaemonContext( working_directory=os.path.abspath(os.path.dirname(__file__)), umask=0x002, - stderr=open("4cat.stderr", "w+"), + stderr=open(Path(config.get('PATH_ROOT'), config.get('PATH_LOGS'), "4cat.stderr"), "w+"), detach_process=True ) as context: import backend.bootstrap as bootstrap diff --git a/backend/bootstrap.py b/backend/bootstrap.py index 14a457054..72bb4c1e7 100644 --- a/backend/bootstrap.py +++ b/backend/bootstrap.py @@ -47,8 +47,9 @@ def run(as_daemon=True): # load everything if config.get("USING_DOCKER"): + as_daemon = True # Rename log if Docker setup - log = Logger(output=not as_daemon, filename='backend_4cat.log') + log = Logger(output=True, filename='backend_4cat.log') else: log = Logger(output=not as_daemon) diff --git a/docker-compose.yml b/docker-compose.yml index 0a4454bad..11b7144b6 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -16,6 +16,7 @@ services: backend: image: digitalmethodsinitiative/4cat:${DOCKER_TAG} container_name: 4cat_backend + init: true restart: unless-stopped env_file: - .env diff --git a/docker-compose_build.yml b/docker-compose_build.yml index ee26cc5c9..069375da4 100644 --- a/docker-compose_build.yml +++ b/docker-compose_build.yml @@ -18,6 +18,7 @@ services: context: . dockerfile: docker/Dockerfile container_name: 4cat_backend + init: true env_file: - .env depends_on: diff --git a/docker-compose_public_ip.yml b/docker-compose_public_ip.yml index 1c00a551d..85c65d2ea 100644 --- a/docker-compose_public_ip.yml +++ b/docker-compose_public_ip.yml @@ -24,6 +24,7 @@ services: backend: image: digitalmethodsinitiative/4cat:${DOCKER_TAG} container_name: 4cat_backend + init: true restart: unless-stopped env_file: - .env diff --git a/docker/docker-entrypoint.sh b/docker/docker-entrypoint.sh index 2fdb5160d..7764907b6 100755 --- a/docker/docker-entrypoint.sh +++ b/docker/docker-entrypoint.sh @@ -1,14 +1,6 @@ #!/bin/sh set -e -exit_backend() { - echo "Exiting backend" - python3 4cat-daemon.py stop - exit 0 -} - -trap exit_backend INT TERM - # Handle any options while test $# != 0 do @@ -56,9 +48,4 @@ echo "http://$SERVER_NAME:$PUBLIC_PORT" echo '' # Start 4CAT backend -python3 4cat-daemon.py start - -# Hang out until SIGTERM received -while true; do - sleep 1 -done +exec python3 -u 4cat-daemon.py -i start diff --git a/setup.py b/setup.py index 33b52a7e7..214b668bc 100644 --- a/setup.py +++ b/setup.py @@ -44,6 +44,7 @@ "PyTumblr==0.1.0", "requests~=2.27", "requests_futures", + "scikit-learn", "scenedetect==0.6.0.3", "spacy==3.4.3", "svgwrite~=1.4.0",