Skip to content

Commit

Permalink
Run supervisord and our rq worker in dev containers
Browse files Browse the repository at this point in the history
To ensure asynchronous processes like submission deletion and hashing
happen in dev containers, run supervisord and our rq worker.

This adds a "run_supervisor" function in dev-deps that creates a
supervisor config under /tmp (which just runs the rq worker), and
starts supervisor.

That function is now invoked in securedrop/bin/run.

The Dockerfiles now install supervisor via pip or pip3.

Fixes freedomofpress#4328.
  • Loading branch information
rmol committed Apr 29, 2019
1 parent d8a6181 commit 8fef967
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 0 deletions.
6 changes: 6 additions & 0 deletions securedrop/bin/dev-deps
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,12 @@ function run_redis() {
setsid redis-server >& /tmp/redis.out || cat /tmp/redis.out
}

function run_supervisor() {
mkdir -p /tmp/supervisor/log /tmp/supervisor/run && printf "[unix_http_server]\nfile=/tmp/supervisor/run/supervisor.sock\nchmod=0700\n\n[supervisord]logfile=/tmp/supervisor/log/supervisord.log\npidfile=/tmp/supervisor/run/supervisord.pid\nchildlogdir=/tmp/supervisor/log\n[rpcinterface:supervisor]\nsupervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface\n\n[supervisorctl]\nserverurl=unix:///tmp/supervisor/run/supervisor.sock\n\n[program:securedrop_worker]\ncommand=/usr/local/bin/rqworker\ndirectory=$(pwd)\nautostart=true\nautorestart=true\nstartretries=3\nstderr_logfile=/tmp/supervisor/log/securedrop_worker.err\nstdout_logfile=/tmp/supervisor/log/securedrop_worker.out\nuser=%s\n" "$USER_NAME" > /tmp/supervisor/supervisor.conf

setsid supervisord -c /tmp/supervisor/supervisor.conf >& /tmp/supervisor/log/supervisor.out || cat /tmp/supervisor/log/supervisor.out
}

function setup_vncauth {
x11vnc -storepasswd freedom /tmp/vncpasswd
}
Expand Down
1 change: 1 addition & 0 deletions securedrop/bin/run
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ source "${BASH_SOURCE%/*}/dev-deps"

run_xvfb &
run_redis &
run_supervisor &
urandom
run_sass --watch &
maybe_create_config_py
Expand Down
2 changes: 2 additions & 0 deletions securedrop/dockerfiles/trusty/python2/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ RUN pip install -U setuptools==40.8.0 && \
pip install -r requirements/securedrop-app-code-requirements.txt && \
pip install -r requirements/test-requirements.txt

RUN pip install supervisor

RUN if test $USER_NAME != root ; then useradd --no-create-home --home-dir /tmp --uid $USER_ID $USER_NAME && echo "$USER_NAME ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers ; fi

STOPSIGNAL SIGKILL
Expand Down
3 changes: 3 additions & 0 deletions securedrop/dockerfiles/xenial/python2/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,15 @@ RUN curl -LO https://launchpad.net/~ubuntu-mozilla-security/+archive/ubuntu/ppa/
RUN gem install sass -v 3.4.23

COPY requirements requirements

RUN pip install -r requirements/securedrop-app-code-requirements.txt && \
pip install -r requirements/test-requirements.txt

# Fixes #4036 pybabel requires latest version of setuptools
RUN pip install --upgrade setuptools

RUN pip install supervisor

RUN if test $USER_NAME != root ; then useradd --no-create-home --home-dir /tmp --uid $USER_ID $USER_NAME && echo "$USER_NAME ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers ; fi

STOPSIGNAL SIGKILL
Expand Down
2 changes: 2 additions & 0 deletions securedrop/dockerfiles/xenial/python3/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ RUN pip3 install -r requirements/securedrop-app-code-requirements.txt && \
# Fixes #4036 pybabel requires latest version of setuptools
RUN pip3 install --upgrade setuptools

RUN pip3 install supervisor

# Temporary workaround: Revert when python 3 is deployed to prod
RUN sudo rm /usr/bin/python && sudo ln -s /usr/bin/python3 /usr/bin/python

Expand Down

0 comments on commit 8fef967

Please sign in to comment.