From 438d0d245f39ced581ebc4c5fb1c5935b21ede1e Mon Sep 17 00:00:00 2001 From: Alastair Porter Date: Tue, 28 Jun 2022 16:44:03 +0200 Subject: [PATCH] Add startup script to run uwsgi in standalone mode without consul --- Dockerfile | 5 +++++ docker/rc.local | 6 ++++++ docker/uwsgistandalone/uwsgi.ini | 10 ++++++++++ docker/uwsgistandalone/uwsgi.service | 3 +++ 4 files changed, 24 insertions(+) create mode 100644 docker/uwsgistandalone/uwsgi.ini create mode 100755 docker/uwsgistandalone/uwsgi.service diff --git a/Dockerfile b/Dockerfile index 9d19af48..e06a6256 100644 --- a/Dockerfile +++ b/Dockerfile @@ -94,6 +94,11 @@ COPY ./docker/uwsgi/uwsgi.ini /etc/uwsgi/uwsgi.ini COPY ./docker/uwsgi/consul-template-uwsgi.conf /etc/consul-template-uwsgi.conf RUN touch /etc/service/uwsgi/down +# Standalone version of uwsgi that doesn't require consul +COPY ./docker/uwsgistandalone/uwsgi.service /etc/service/uwsgistandalone/run +COPY ./docker/uwsgistandalone/uwsgi.ini /etc/uwsgi/uwsgi.ini +RUN touch /etc/service/uwsgistandalone/down + # hl_extractor service files COPY ./docker/hl_extractor/hl_extractor.service /etc/service/hl_extractor/run COPY docker/hl_extractor/consul-template-hl-extractor.conf /etc/consul-template-hl-extractor.conf diff --git a/docker/rc.local b/docker/rc.local index c52d8a0b..f82cf901 100755 --- a/docker/rc.local +++ b/docker/rc.local @@ -7,6 +7,12 @@ # All services contain a name and an environment (e.g. acousticbrainz-web-prod). # Set DEPLOY_ENV to 'prod' or 'beta' to indicate this +if [ "${CONTAINER_ROLE}" = "acousticbrainz-standalone" ] +then + rm -f /etc/service/uwsgistandalone/down + exit 0 +fi + if [ "${CONTAINER_ROLE}" = "acousticbrainz-web-${DEPLOY_ENV}" ] then rm -f /etc/service/uwsgi/down diff --git a/docker/uwsgistandalone/uwsgi.ini b/docker/uwsgistandalone/uwsgi.ini new file mode 100644 index 00000000..a35fb0c4 --- /dev/null +++ b/docker/uwsgistandalone/uwsgi.ini @@ -0,0 +1,10 @@ +[uwsgi] +master = true +http = 0.0.0.0:3031 +module = server +callable = application +chdir = /code +enable-threads = true +processes = 100 +log-x-forwarded-for = true +disable-logging = true diff --git a/docker/uwsgistandalone/uwsgi.service b/docker/uwsgistandalone/uwsgi.service new file mode 100755 index 00000000..eb79a57f --- /dev/null +++ b/docker/uwsgistandalone/uwsgi.service @@ -0,0 +1,3 @@ +#!/bin/bash + +exec chpst -uacousticbrainz:acousticbrainz uwsgi --die-on-term /etc/uwsgi/uwsgi.ini