From e4de48822542aa592e4e2dc425ccddddabdf462b Mon Sep 17 00:00:00 2001 From: f Date: Sun, 27 Sep 2020 14:04:11 -0300 Subject: [PATCH] puma ya no daemoniza por su cuenta --- Dockerfile | 7 ++----- Gemfile | 10 +++++----- Procfile | 2 +- entrypoint.sh | 4 ++++ monit.conf | 5 ++--- prometheus.sh | 4 ---- 6 files changed, 14 insertions(+), 18 deletions(-) delete mode 100755 prometheus.sh diff --git a/Dockerfile b/Dockerfile index ef518d8d..7226284d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -58,10 +58,7 @@ COPY --chown=app:root ./config/credentials.yml.enc ./config/ COPY --chown=app:www-data ./public/assets-production ./public/assets COPY --chown=app:www-data ./public/packs-production ./public/packs -# Eliminar la necesidad de un runtime JS en producción, porque los -# assets ya están pre-compilados. -RUN sed -re "/(sassc|uglifier|bootstrap|coffee-rails)/d" -i Gemfile -RUN bundle clean +# Limpieza RUN rm -rf ./node_modules ./tmp/cache ./.git # Contenedor final @@ -113,7 +110,7 @@ RUN install -m 755 /srv/http/sync_assets.sh /usr/local/bin/sync_assets # Instalar la configuración de monit RUN install -m 640 -o root -g root /srv/http/monit.conf /etc/monit.d/sutty.conf RUN apk add --no-cache daemonize ruby-webrick -RUN install -m 755 /srv/http/prometheus.sh /usr/local/bin/prometheus +RUN install -m 755 /srv/http/entrypoint.sh /usr/local/bin/sutty # Mantener estos directorios! VOLUME "/srv/http/data" diff --git a/Gemfile b/Gemfile index bddf7448..df939af3 100644 --- a/Gemfile +++ b/Gemfile @@ -23,10 +23,6 @@ gem 'dotenv-rails', require: 'dotenv/rails-now' gem 'rails', '~> 6' # Use Puma as the app server gem 'puma' -# Use SCSS for stylesheets -gem 'sassc-rails' -# Use Uglifier as compressor for JavaScript assets -gem 'uglifier', '>= 1.3.0' # See https://github.com/rails/execjs#readme for more supported runtimes # gem 'therubyracer', platforms: :ruby @@ -39,7 +35,6 @@ gem 'jbuilder', '~> 2.5' # Use ActiveModel has_secure_password gem 'bcrypt', '~> 3.1.7' gem 'blazer' -gem 'bootstrap', '~> 4' gem 'commonmarker' gem 'devise' gem 'devise-i18n' @@ -96,6 +91,11 @@ group :production do end group :development, :test do + # Use SCSS for stylesheets + gem 'sassc-rails' + # Use Uglifier as compressor for JavaScript assets + gem 'uglifier', '>= 1.3.0' + gem 'bootstrap', '~> 4' gem 'derailed_benchmarks' gem 'pry' # Adds support for Capybara system testing and selenium driver diff --git a/Procfile b/Procfile index 2c951ac0..b308ffd5 100644 --- a/Procfile +++ b/Procfile @@ -1,5 +1,5 @@ migrate: bundle exec rake db:prepare db:seed -sutty: bundle exec puma -d config.ru +sutty: bundle exec puma config.ru blazer_5m: bundle exec rake blazer:run_checks SCHEDULE="5 minutes" blazer_1h: bundle exec rake blazer:run_checks SCHEDULE="1 hour" blazer_1d: bundle exec rake blazer:run_checks SCHEDULE="1 day" diff --git a/entrypoint.sh b/entrypoint.sh index 98e68700..3ae103bb 100644 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -2,5 +2,9 @@ set -e case $1 in + sutty) + su app -c "cd /srv/http && foreman start migrate" + daemonize -c /srv/http -u app /usr/bin/foreman start sutty + ;; prometheus) daemonize -c /srv/http -p /tmp/prometheus.pid -l /tmp/prometheus.pid -u app /usr/bin/foreman start prometheus ;; esac diff --git a/monit.conf b/monit.conf index c3663978..b8c9e442 100644 --- a/monit.conf +++ b/monit.conf @@ -1,10 +1,9 @@ check process sutty with pidfile /srv/http/tmp/puma.pid - start program = "/bin/sh -c 'cd /srv/http && foreman start migrate && foreman start sutty'" - as uid "app" and gid "www-data" + start program = "/usr/local/bin/sutty sutty" stop program = "/bin/sh -c 'cat /srv/http/tmp/puma.pid | xargs kill'" check process prometheus with pidfile /tmp/prometheus.pid - start program = "/usr/local/bin/prometheus" + start program = "/usr/local/bin/sutty prometheus" stop program = "/bin/sh -c 'cat /tmp/prometheus.pid | xargs kill'" check program sync_assets diff --git a/prometheus.sh b/prometheus.sh deleted file mode 100755 index 639e1d24..00000000 --- a/prometheus.sh +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/sh -set -e - -daemonize -c /srv/http -p /tmp/prometheus.pid -l /tmp/prometheus.pid -u app /usr/bin/foreman start prometheus