From 3695dd1a2e2d7a6a338d35e3f11db8f81fb8c16d Mon Sep 17 00:00:00 2001 From: Connor Poole Date: Sun, 6 Nov 2016 22:18:38 -0800 Subject: [PATCH] Added ability to set puma worker timeout --- Dockerfile | 6 +++--- README.md | 1 + rootfs/init | 10 ++++++++-- rootfs/portus/config/puma.rb | 4 ++++ 4 files changed, 16 insertions(+), 5 deletions(-) create mode 100644 rootfs/portus/config/puma.rb diff --git a/Dockerfile b/Dockerfile index 75fc2fd..6982b2c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -18,9 +18,9 @@ ENV PORTUS_VERSION="2.1.0" \ RUN apk --no-cache add --update -t deps git gcc make musl-dev libxml2-dev \ libxslt-dev mariadb-dev openssl-dev libffi-dev curl-dev \ - && apk --no-cache add bash ruby-bundler ruby-dev nodejs tzdata libxslt \ - mariadb-libs mariadb-client openssl ruby-io-console ruby-bigdecimal \ - mariadb-client-libs libcurl \ + && apk --no-cache add bash ruby-bundler ruby-dev ruby-rdoc ruby-irb \ + nodejs tzdata libxslt mariadb-libs mariadb-client openssl ruby-io-console \ + ruby-bigdecimal mariadb-client-libs libcurl \ && echo 'gem: --verbose --no-document' > /etc/gemrc; cd /tmp \ && git clone https://github.com/SUSE/Portus.git . \ && git checkout ${PORTUS_VERSION}; mkdir /portus \ diff --git a/README.md b/README.md index 514ed74..390db1b 100644 --- a/README.md +++ b/README.md @@ -81,6 +81,7 @@ cd portus && docker run -it --rm \ --env RAILS_ENV=production \ --env PUMA_SSL_KEY=/certs/server-key.pem \ --env PUMA_SSL_CRT=/certs/server-crt.pem \ +--env PUMA_WORKER_TIMEOUT=60 \ --env PUMA_IP=127.0.0.1 \ --env PUMA_PORT=443 \ --env PUMA_WORKERS=4 \ diff --git a/rootfs/init b/rootfs/init index 3fb46b1..2b28746 100755 --- a/rootfs/init +++ b/rootfs/init @@ -7,6 +7,7 @@ CONFIG_FILE='/portus/config/config.yml' DB_CONFIG_FILE='/portus/config/database.yml' SECRETS_CONFIG_FILE='/portus/config/secrets.yml' +PUMA_CONFIG_FILE='portus/config/puma.rb' # Machine fqdn: : ${PORTUS_MACHINE_FQDN:=127.0.0.1} && \ @@ -60,6 +61,11 @@ sed -i "s#XXX-PORTUS_ENCRYPTION_PRIVATE_KEY_PATH-XXX#${PORTUS_ENCRYPTION_PRIVATE : ${PORTUS_PORTUS_PASSWORD:=portus} && \ sed -i "s#XXX-PORTUS_PORTUS_PASSWORD-XXX#${PORTUS_PORTUS_PASSWORD}#" ${SECRETS_CONFIG_FILE} +# Puma worker timeout: +: ${PUMA_WORKER_TIMEOUT:=60} && \ +sed -i "s#XXX-PUMA_WORKER_TIMEOUT-XXX#${PUMA_WORKER_TIMEOUT}#" ${PUMA_CONFIG_FILE} + + # Set Rack and Rails environment: export RACK_ENV=${RACK_ENV:-production} export RAILS_ENV=${RAILS_ENV:-production} @@ -101,5 +107,5 @@ mysql -h ${MARIADB_HOST} -P ${MARIADB_PORT} -u ${MARIADB_USER} -p${MARIADB_PASSW export SSL_CERT_DIR=${SSL_CERT_DIR:-/certs:/usr/local/share/ca-certificates:/etc/ssl/certs} && c_rehash [[ "${PORTUS_CHECK_SSL_USAGE_ENABLED}" == "true" && "${PUMA_SSL_KEY}" && "${PUMA_SSL_CRT}" ]] && \ -exec env puma -e ${RACK_ENV} -b "ssl://${PUMA_IP:-0.0.0.0}:${PUMA_PORT:-443}?key=${PUMA_SSL_KEY}&cert=${PUMA_SSL_CRT}" -w ${PUMA_WORKERS:-3} || -exec env puma -e ${RACK_ENV} -b "tcp://${PUMA_IP:-0.0.0.0}:${PUMA_PORT:-80}" -w ${PUMA_WORKERS:-3} +exec env puma -e ${RACK_ENV} -b "ssl://${PUMA_IP:-0.0.0.0}:${PUMA_PORT:-443}?key=${PUMA_SSL_KEY}&cert=${PUMA_SSL_CRT}" -w ${PUMA_WORKERS:-3} -C /portus/config/puma.rb || +exec env puma -e ${RACK_ENV} -b "tcp://${PUMA_IP:-0.0.0.0}:${PUMA_PORT:-80}" -w ${PUMA_WORKERS:-3} -C /portus/config/puma.rb diff --git a/rootfs/portus/config/puma.rb b/rootfs/portus/config/puma.rb new file mode 100644 index 0000000..8e47c5e --- /dev/null +++ b/rootfs/portus/config/puma.rb @@ -0,0 +1,4 @@ +#!/usr/bin/env puma + +threads 0, 16 +worker_timeout XXX-PUMA_WORKER_TIMEOUT-XXX