Skip to content

Commit 3dd2b86

Browse files
committed
Stream jupyter server logs to a file
By streaming the logs also to a file users can access them from inside the container which helps them debug issues without having to ask an admin.
1 parent f3229c1 commit 3dd2b86

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

repo2docker/buildpacks/repo2docker-entrypoint

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,19 @@
22
# lightest possible entrypoint that ensures that
33
# we use a login shell to get a fully configured shell environment
44
# (e.g. sourcing /etc/profile.d, ~/.bashrc, and friends)
5+
6+
# Setup a file descriptor (FD) that is connected to a tee process which
7+
# writes its input to $REPO_DIR/.jupyter-server-log.txt
8+
# We later use this FD as a place to redirect the output of the actual
9+
# command to. We can't add `tee` to the command directly as that will prevent
10+
# the container from exiting when `docker stop` is run.
11+
exec {log_fd}> >(exec tee $REPO_DIR/.jupyter-server-log.txt)
12+
513
if [[ ! -z "${R2D_ENTRYPOINT:-}" ]]; then
614
if [[ ! -x "$R2D_ENTRYPOINT" ]]; then
715
chmod u+x "$R2D_ENTRYPOINT"
816
fi
9-
exec "$R2D_ENTRYPOINT" "$@"
17+
exec "$R2D_ENTRYPOINT" "$@" >&"$log_fd" 2>&1
1018
else
11-
exec "$@"
19+
exec "$@" >&"$log_fd" 2>&1
1220
fi

0 commit comments

Comments
 (0)