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

Commit bac612f

Browse files
committed
Add: Send Celery log data to the Docker logs.
Docs: Prettify a bit.
1 parent cf29f3a commit bac612f

File tree

1 file changed

+16
-5
lines changed

1 file changed

+16
-5
lines changed

docker/docker_tools_misc.py

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ 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 &",
91+
"--concurrency=3 --loglevel=info --logfile=/dev/stdout &",
9292
cwd=f"{env.RUNESTONE_PATH}/modules",
9393
)
9494

@@ -100,14 +100,15 @@ def _start_servers(dev: bool) -> None:
100100
# This much match the address in `./nginx/sites-available/runestone.template`.
101101
"--bind unix:/run/fastapi.sock "
102102
+ ("--reload " if dev else "")
103-
+ "2>&1 > /proc/1/fd/1 &", # This redirect ensures output ends up in the docker log
103+
# This redirect ensures output ends up in the Docker log.
104+
+ "2>&1 > /proc/1/fd/1 &",
104105
"service nginx start",
105106
"poetry run gunicorn -D --config $RUNESTONE_PATH/docker/gunicorn_config/web2py_config.py &",
106107
cwd=f"{env.RUNESTONE_PATH}/docker/gunicorn_config",
107108
)
108109

109110
# Start the script to collect tickets and store them in the database. Most useful
110-
# for a production environment with several worker containers
111+
# for a production environment with several worker containers.
111112
xqt(
112113
f"cp {env.RUNESTONE_PATH}/scripts/tickets2db.py {env.WEB2PY_PATH}",
113114
"python web2py.py -M -S runestone --run tickets2db.py &",
@@ -137,6 +138,8 @@ def _stop_servers() -> None:
137138
)
138139

139140

141+
# ``restart_servers``
142+
# -------------------
140143
@click.command()
141144
@click.option(
142145
"--dev/--no-dev",
@@ -152,6 +155,8 @@ def restart_servers(dev):
152155
_start_servers()
153156

154157

158+
# ``reloadbks``
159+
# -------------
155160
@click.command()
156161
def reloadbks() -> None:
157162
"""
@@ -162,7 +167,8 @@ def reloadbks() -> None:
162167
pid = pfile.read().strip()
163168

164169
pid = int(pid)
165-
os.kill(pid, 1) # send the HUP signal to bookserver
170+
# send the HUP signal to the BookServer.
171+
os.kill(pid, 1)
166172

167173

168174
# ``test``
@@ -179,12 +185,17 @@ def reloadbks() -> None:
179185
@click.argument("passthrough", nargs=-1, type=click.UNPROCESSED)
180186
def test(bks: bool, rc: bool, rs: bool, passthrough: Tuple) -> None:
181187
"""
182-
Run unit tests.
188+
Run unit tests. All tests are disabled by default; manually select which test to run.
183189
184190
PASSTHROUGH: These arguments are passed directly to the underlying "pytest" command. To pass options to this command, prefix this argument with "--". For example, use "docker_tools.py test -- -k test_just_this" instead of "docker_tools.py test -k test_just_this" (which produces an error).
185191
186192
"""
187193
ensure_in_docker()
194+
if not bks and not rc and not rs:
195+
sys.exit(
196+
"ERROR: No tests selected to run. Pass any combination of --rs, --rs,\n"
197+
"and/or --bks."
198+
)
188199
_stop_servers()
189200
pytest = "$RUNESTONE_PATH/.venv/bin/pytest"
190201
passthrough_args = " ".join(passthrough)

0 commit comments

Comments
 (0)