Skip to content

Commit

Permalink
Migrate supervisord to parallel (#1592)
Browse files Browse the repository at this point in the history
  • Loading branch information
liranbg committed Mar 25, 2020
1 parent 1b6bb38 commit 21bfb3f
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 20 deletions.
13 changes: 8 additions & 5 deletions cmd/dashboard/docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -61,16 +61,19 @@ ARG DOCKER_CLI_VERSION="18.09.6"

ENV DOWNLOAD_URL="https://download.docker.com/linux/static/stable/x86_64/docker-$DOCKER_CLI_VERSION.tgz"

RUN apk --update --no-cache add ca-certificates git curl supervisor \
RUN apk --update --no-cache add ca-certificates git curl parallel \
&& mkdir -p /tmp/download \
&& curl -L $DOWNLOAD_URL | tar -xz -C /tmp/download \
&& mv /tmp/download/docker/docker /usr/local/bin/ \
&& rm -rf /tmp/download \
&& apk del curl

# copy supervisord configuration files
COPY cmd/dashboard/docker/supervisor.conf /etc/supervisor.conf
COPY cmd/dashboard/docker/dashboard.sv.conf /etc/supervisor/conf.d/dashboard.conf
# copy runners
COPY cmd/dashboard/docker/runners /runners
COPY cmd/dashboard/docker/runner.sh /runner.sh

# make them executable
RUN chmod +x /runners/*.sh /runner.sh

# copy nginx config
COPY cmd/dashboard/docker/nginx.conf /etc/nginx/conf.d/default.conf
Expand All @@ -85,4 +88,4 @@ COPY --from=build-binary /go/src/github.com/nuclio/nuclio/dashboard /usr/local/b
ARG NUCLIO_VERSION_INFO_FILE_CONTENTS
RUN mkdir -p /etc/nuclio && echo ${NUCLIO_VERSION_INFO_FILE_CONTENTS} > /etc/nuclio/version_info.json

CMD ["supervisord", "-c", "/etc/supervisor.conf", "-l", "/etc/supervisor.log", "-j", "/etc/supervisor.pid"]
CMD ["sh", "-c", "./runner.sh"]
10 changes: 0 additions & 10 deletions cmd/dashboard/docker/dashboard.sv.conf

This file was deleted.

27 changes: 27 additions & 0 deletions cmd/dashboard/docker/runner.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/usr/bin/env sh

_term() {
echo "Signal caught ... cleaning up"
kill -TERM "$child" 2>/dev/null
}

trap _term SIGTERM
trap _term SIGINT

echo "Running in parallel"

parallel --citation

# buffer output on line basis
# exit when the first job fails, kill all running jobs.
# upon unexpected termination, signal jobs before killing (signal, timeout)
# execute all *.sh files in parallel
parallel \
--line-buffer \
--halt now,fail=1 \
--termseq INT,200,TERM,100,KILL,25 \
'{}' ::: /runners/*.sh &

child=$!
wait "$child"
echo "Exiting"
4 changes: 4 additions & 0 deletions cmd/dashboard/docker/runners/dashboard.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/env sh

echo "Starting dashboard"
/usr/local/bin/dashboard --docker-key-dir /etc/nuclio/dashboard/registry-credentials --listen-addr :18070 2>&1
4 changes: 4 additions & 0 deletions cmd/dashboard/docker/runners/nginx.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/env sh

echo "Starting nginx"
/usr/sbin/nginx -g "daemon off;" &> /var/log/nginx/logs.log
5 changes: 0 additions & 5 deletions cmd/dashboard/docker/supervisor.conf

This file was deleted.

0 comments on commit 21bfb3f

Please sign in to comment.