From 56e4d9145f911ee62c1473188c25b1c38c27b3c7 Mon Sep 17 00:00:00 2001 From: f Date: Wed, 26 Feb 2020 12:22:34 -0300 Subject: [PATCH] deploy --- Makefile | 2 ++ config/deploy.rb | 8 ++++++-- config/deploy/production.rb | 2 +- config/environments/production.rb | 6 +++--- lib/capistrano/tasks/puma.rake | 21 +++++++++++++++++++++ 5 files changed, 33 insertions(+), 6 deletions(-) create mode 100644 lib/capistrano/tasks/puma.rake diff --git a/Makefile b/Makefile index dd0d2df..7350805 100644 --- a/Makefile +++ b/Makefile @@ -11,6 +11,8 @@ doc: ./bin/yardoc --output-dir=./docs/ \ app/controllers/*.rb \ app/models/*.rb + chmod -R o=g docs/ + rsync -av --delete-after docs/ lumi@partidopirata.com.ar:/srv/http/api.lumi.partidopirata.com.ar/deploy/shared/docs/ clean: rm -f log/*.log diff --git a/config/deploy.rb b/config/deploy.rb index 79c7373..e2d4c63 100644 --- a/config/deploy.rb +++ b/config/deploy.rb @@ -5,7 +5,7 @@ lock '~> 3.12.0' set :application, 'lumi' set :repo_url, 'https://0xacab.org/pip/miniloom/api.git' set :deploy_to, '/srv/http/api.lumi.partidopirata.com.ar/deploy' -append :linked_dirs, 'log', 'tmp/pids', 'tmp/cache', 'tmp/sockets', 'public/system', 'data', '.bundle' +append :linked_dirs, 'log', 'tmp/pids', 'tmp/cache', 'tmp/sockets', 'public/system', 'data', '.bundle', 'docs' set :bundle_flags, '--deployment' set :bundle_jobs, 1 set :bundle_env_variables, { nokogiri_use_system_libraries: 1 } @@ -14,5 +14,9 @@ set :ssh_options, verify_host_key: :always set :default_env, { rails_env: 'production', - rails_master_key: File.read('config/master.key') + rails_master_key: File.read('config/master.key'), + web_concurrency: '1' } + +after 'deploy:published', 'puma:stop' +after 'puma:stop', 'puma:start' diff --git a/config/deploy/production.rb b/config/deploy/production.rb index 99bd770..845f436 100644 --- a/config/deploy/production.rb +++ b/config/deploy/production.rb @@ -9,7 +9,7 @@ # server "example.com", user: "deploy", roles: %w{app web}, other_property: :other_value # server "db.example.com", user: "deploy", roles: %w{db} -server 'partidopirata.com.ar', user: 'lumi', roles: %w[db web] +server 'partidopirata.com.ar', user: 'lumi', roles: %w[db app web] # role-based syntax # ================== diff --git a/config/environments/production.rb b/config/environments/production.rb index 970f384..69e5bf4 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -20,7 +20,7 @@ Rails.application.configure do # Ensures that a master key has been made available in either # ENV["RAILS_MASTER_KEY"] or in config/master.key. This key is used to # decrypt credentials (and other encrypted files). - # config.require_master_key = true + config.require_master_key = true # Disable serving static files from the `/public` folder by default # since Apache or NGINX already handles this. @@ -33,7 +33,7 @@ Rails.application.configure do # Specifies the header that your server uses for sending files. # config.action_dispatch.x_sendfile_header = 'X-Sendfile' # for Apache - # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for NGINX + config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for NGINX # Store uploaded files on the local file system (see # config/storage.yml for options) @@ -51,7 +51,7 @@ Rails.application.configure do # Use the lowest log level to ensure availability of diagnostic # information when problems arise. - config.log_level = :debug + config.log_level = :info # Prepend all log lines with the following tags. config.log_tags = [:request_id] diff --git a/lib/capistrano/tasks/puma.rake b/lib/capistrano/tasks/puma.rake new file mode 100644 index 0000000..4270662 --- /dev/null +++ b/lib/capistrano/tasks/puma.rake @@ -0,0 +1,21 @@ +# frozen_string_literal: true + +namespace :pumo do + desc 'Start puma' + task :start do + on roles(:web) do + within current_path do + execute :bundle, :exec, :puma, '--daemon' + end + end + end + + desc 'Stop puma' + task :stop do + on roles(:web) do + within current_path do + execute "cat #{current_path}/tmp/puma.pid | xargs kill" + end + end + end +end