Skip to content

Commit

Permalink
Preliminary heartbeat on commands for terminals
Browse files Browse the repository at this point in the history
The terminal window in the jupyter notebook doesn't communicate with the
home server on each command.  Neither do the other various kernels.  The
notebook kernels *do* send checkpoints though.  The checkpoints keep the
container alive appropriately.

The terminal does not do this, thus sessions lasting more than lifetimes
expire, and the learners lose their environment and context.  This
commit adds a pre-command script example.  In order to utilize this, all
codelab/jupyter/etc containers need a single base image.

The heartbeat is defined as a pre-execute script from:

https://github.com/rcaloras/bash-preexec

which runs a wget command to tell the home server the container is
still alive.
  • Loading branch information
ksshannon committed Feb 12, 2019
1 parent de204cf commit 8ab67b3
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
16 changes: 14 additions & 2 deletions docker/rc/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,20 @@ FROM jupyter/minimal-notebook
# Minimal notebook for testing
MAINTAINER Kyle Shannon <kyle@pobox.com>

USER $NB_USER
USER root
RUN apt-get update && \
apt-get install -y --no-install-recommends curl && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*

USER $NB_USER
RUN curl \
https://raw.githubusercontent.com/rcaloras/bash-preexec/master/bash-preexec.sh \
-o ~/.bash-preexec.sh
# from https://github.com/rcaloras/bash-preexec
RUN echo '[[ -f ~/.bash-preexec.sh ]] && source ~/.bash-preexec.sh' >> ~/.bashrc
RUN echo 'source ~/.bash-preexec.sh' >> ~/.bashrc
RUN echo 'precmd() { wget -O /dev/null -o /dev/null http://127.0.0.1:8888/book/$TMPNB_ID/; }' >> ~/.bashrc
WORKDIR $HOME

RUN echo "Hello, world!!\n" > hello.txt

1 change: 1 addition & 0 deletions pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,7 @@ func (p *notebookPool) newNotebook(image string, pull bool, email string) (*note

tokenArg := fmt.Sprintf(`--NotebookApp.token="%s"`, p.token)
var env []string
env = append(env, fmt.Sprintf("TMPNB_ID=%s", key))
if p.disableJupyterAuth {
tokenArg = fmt.Sprintf(`--NotebookApp.token=""`)
} else {
Expand Down

0 comments on commit 8ab67b3

Please sign in to comment.