Skip to content
This repository was archived by the owner on Jun 30, 2024. It is now read-only.

Commit 7ec2446

Browse files
committed
Fix: Correctly redirect stdout to Docker, even across server restarts.
Minor code clean.
1 parent bac612f commit 7ec2446

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

docker/docker_tools_misc.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,9 @@ def _start_servers(dev: bool) -> None:
8888
xqt(
8989
'sudo -u www-data env "PATH=$PATH" "REDIS_URI=$REDIS_URI" '
9090
"poetry run celery --app=scheduled_builder worker --pool=threads "
91-
"--concurrency=3 --loglevel=info --logfile=/dev/stdout &",
91+
"--concurrency=3 --loglevel=info "
92+
# This redirect ensures output ends up in the Docker log even if the servers are restarted. Sending to ``/dev/stdout`` only works at initial startup, but doesn't redirect after the servers are restarted.
93+
"--logfile=/proc/1/fd/1 &",
9294
cwd=f"{env.RUNESTONE_PATH}/modules",
9395
)
9496

@@ -98,9 +100,8 @@ def _start_servers(dev: bool) -> None:
98100
"--error_path /tmp "
99101
"--gconfig $RUNESTONE_PATH/docker/gunicorn_config/fastapi_config.py "
100102
# This much match the address in `./nginx/sites-available/runestone.template`.
101-
"--bind unix:/run/fastapi.sock "
102-
+ ("--reload " if dev else "")
103-
# This redirect ensures output ends up in the Docker log.
103+
f"--bind unix:/run/fastapi.sock {'--reload ' if dev else ''}"
104+
# See previous comment on redirecting output to ``/dev/stdout`` even after server restarts.
104105
+ "2>&1 > /proc/1/fd/1 &",
105106
"service nginx start",
106107
"poetry run gunicorn -D --config $RUNESTONE_PATH/docker/gunicorn_config/web2py_config.py &",
@@ -272,7 +273,7 @@ def ensure_in_docker(
272273
return True
273274
# Get the name of the container running the Runestone servers.
274275
res = subprocess.run(
275-
'docker ps --filter "ancestor=runestone/server" --format "{{.Names}}"',
276+
'docker ps --filter "ancestor=runestone/server" --format "{{.Names}}"',
276277
shell=True,
277278
capture_output=True,
278279
text=True,

0 commit comments

Comments
 (0)