seuros / capistrano-puma

Puma integration for Capistrano
https://github.com/seuros/capistrano-puma
MIT License
615 stars 299 forks source link

Input/output error @ io_writev - <STDOUT> (Errno::EIO) #287

Closed mzalendo254 closed 3 years ago

mzalendo254 commented 5 years ago

When I deploy an application with capistrano-puma, everything goes according to plan including the starting of the app server, 'puma'. However when I try to access the web app on the browser I get the following error /var/www/mercury/shared/bundle/ruby/2.5.0/gems/puma-4.1.0/lib/puma/events.rb:69:inwrite': Input/output error @ io_writev - (Errno::EIO)`

Configs

deploy.erb

# config valid only for current version of Capistrano
# lock "3.9.0"

require 'capistrano-db-tasks'

# set :rvm_map_bins, %w{gem rake ruby rails bundle}
set :disallow_pushing, false

# set :use_sudo, true

set :application, "vellum"
set :repo_url, "git@xxxxxx.com:yyyyyyyy/vellum.git"

# Default branch is :master
ask :branch, `git rev-parse --abbrev-ref HEAD`.chomp

# Default deploy_to directory is /var/www/my_app_name
set :deploy_to, "/var/www/vellum"

set :app_path, "#{deploy_to}/current"

# Default value for :format is :airbrussh.
# set :format, :airbrussh

# You can configure the Airbrussh format using :format_options.
# These are the defaults.
# set :format_options, command_output: true, log_file: "log/capistrano.log", color: :auto, truncate: :auto

# Default value for :pty is false
set :pty, true

# Default value for :linked_files is []
append :linked_files, "config/database.yml", "config/secrets.yml", "config/application.yml"

# Default value for linked_dirs is []
append :linked_dirs, "log", "tmp/pids", "tmp/cache", "tmp/sockets", "public/system", 'public/uploads'

# Default value for default_env is {}
# set :default_env, { path: "/opt/ruby/bin:$PATH" }

# Default value for local_user is ENV['USER']
# set :local_user, -> { `git config user.name`.chomp }

# Default value for keep_releases is 5
set :keep_releases, 10

### Puma Configuration ###
set :nginx_use_ssl, true
set :puma_workers, 2

Capfile

# Load DSL and set up stages
require "capistrano/setup"

# Include default deployment tasks
require "capistrano/rvm"
require "capistrano/deploy"
require "capistrano/bundler"
require "capistrano/rails/assets"
require "capistrano/rails/migrations"
require 'capistrano/puma'

# Load the SCM plugin appropriate to your project:
#
# require "capistrano/scm/hg"
# install_plugin Capistrano::SCM::Hg
# or
# require "capistrano/scm/svn"
# install_plugin Capistrano::SCM::Svn
# or
require "capistrano/scm/git"
install_plugin Capistrano::SCM::Git
install_plugin Capistrano::Puma  # Default puma tasks
install_plugin Capistrano::Puma::Workers  # if you want to control the workers (in cluster mode)
install_plugin Capistrano::Puma::Jungle # if you need the jungle tasks

deploy/production.rb

set :port, 22
set :user, 'kelvin'
set :application, 'vellum'
set :deploy_to, '/var/www/vellum'
set :deploy_via, :remote_cache
set :use_sudo, false

server '178.128.246.249',
  roles: [:web, :app, :db],
  port: fetch(:port),
  user: fetch(:user),
  primary: true

set :deploy_to, "/var/www/#{fetch(:application)}"
set :ssh_options, {
  forward_agent: true,
  auth_methods: %w(publickey),
  user: 'kelvin',
}

set :rails_env, :production
set :conditionally_migrate, true

Nginx Config File

upstream puma_vellum_production {
  server unix:/var/www/vellum/shared/tmp/sockets/puma.sock fail_timeout=0;
}

# for redirecting to https version of the site
server {
       listen 80;
       rewrite ^(.*) https://$host$1 permanent;
}

server {
    listen  80;
    server_name  www.mercury.vellum.co.ke;
    rewrite ^(.*) http://mercury.vellum.co.ke$1 permanent;
}

server {
  listen [::]:443 ssl ipv6only=on;
  listen 443 ssl; 
  server_name mercury.vellum.co.ke;
  ssl on;
  ssl_certificate /etc/letsencrypt/live/vellum.co.ke/fullchain.pem;
  ssl_certificate_key /etc/letsencrypt/live/vellum.co.ke/privkey.pem;
  ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; 
  include /etc/letsencrypt/options-ssl-nginx.conf;
  root /var/www/mercury/current/public;
  try_files $uri/index.html $uri @puma_mercury_production;

  client_max_body_size 4G;
  keepalive_timeout 10;

  error_page 500 502 504 /500.html;
  error_page 503 @503;

  location @puma_vellum_production {
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header Host $host;
    proxy_redirect off;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection "Upgrade";
    proxy_set_header X-Forwarded-Proto https;
    proxy_pass http://puma_vellum_production;
    # limit_req zone=one;
    access_log /var/www/vellum/shared/log/nginx.access.log;
    error_log /var/www/vellum/shared/log/nginx.error.log;
  }

  location ^~ /assets/ {
    gzip_static on;
    # expires max;
    # add_header Cache-Control public;
    add_header Cache-Control no-cache;
    expires -1;
  }

  location = /50x.html {
    root html;
  }

  location = /404.html {
    root html;
  }

  location @503 {
    error_page 405 = /system/maintenance.html;
    if (-f $document_root/system/maintenance.html) {
      rewrite ^(.*)$ /system/maintenance.html break;
    }
    rewrite ^(.*)$ /503.html break;
  }

  if ($request_method !~ ^(GET|HEAD|PUT|PATCH|POST|DELETE|OPTIONS)$ ){
    return 405;
  }

  if (-f $document_root/system/maintenance.html) {
    return 503;
  }
}
mzalendo254 commented 5 years ago

nginx access log

172.247.109.26 - - [15/Aug/2019:10:38:02 +0000] "GET / HTTP/1.1" 200 32761 "https://178.128.246.249/" "Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/38.0.2125.122 Safari/537.36 SE 2.X MetaSr 1.0"
172.247.109.168 - - [15/Aug/2019:10:38:02 +0000] "GET / HTTP/1.1" 200 32761 "http://178.128.246.249/" "Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/38.0.2125.122 Safari/537.36 SE 2.X MetaSr 1.0"
60.191.38.77 - - [15/Aug/2019:10:49:02 +0000] "GET / HTTP/1.1" 200 32761 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.11; rv:47.0) Gecko/20100101 Firefox/47.0"
60.191.38.77 - - [15/Aug/2019:13:55:42 +0000] "GET / HTTP/1.1" 200 32761 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.11; rv:47.0) Gecko/20100101 Firefox/47.0"
212.83.146.233 - - [15/Aug/2019:18:04:48 +0000] "GET / HTTP/1.1" 200 32761 "-" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:58.0) Gecko/20100101 Firefox/58.0"
141.101.104.203 - - [15/Aug/2019:19:53:51 +0000] "GET / HTTP/1.1" 200 32761 "-" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.100 Safari/537.36"
172.69.54.79 - - [16/Aug/2019:00:49:50 +0000] "GET / HTTP/1.1" 200 32761 "-" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.100 Safari/537.36"
77.247.110.236 - - [16/Aug/2019:04:57:47 +0000] "GET //a2billing/customer/templates/default/footer.tpl HTTP/1.1" 404 1722 "-" "python-requests/2.6.0 CPython/2.7.5 Linux/3.10.0-957.21.3.el7.x86_64"
41.80.249.140 - - [16/Aug/2019:05:32:43 +0000] "GET / HTTP/1.1" 200 32761 "-" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.100 Safari/537.36"
141.101.77.180 - - [16/Aug/2019:06:24:14 +0000] "GET / HTTP/1.1" 200 32761 "-" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.100 Safari/537.36"

nginx error log

2019/04/25 13:17:23 [error] 11594#11594: *4 upstream timed out (110: Connection timed out) while reading response header from upstream, client: 162.158.42.36, server: beta.vellum.co.ke, request: "GET / HTTP/1.1", upstream: "http://unix:/var/www/vellum/shared/tmp/sockets/puma.sock/", host: "beta.vellum.co.ke"
2019/04/25 13:25:31 [error] 16613#16613: *1 upstream timed out (110: Connection timed out) while reading response header from upstream, client: 162.158.42.36, server: beta.vellum.co.ke, request: "GET / HTTP/1.1", upstream: "http://unix:/var/www/vellum/shared/tmp/sockets/puma.sock/", host: "beta.vellum.co.ke"
2019/04/25 13:25:43 [error] 16613#16613: *3 upstream timed out (110: Connection timed out) while reading response header from upstream, client: 162.158.42.36, server: beta.vellum.co.ke, request: "GET / HTTP/1.1", upstream: "http://unix:/var/www/vellum/shared/tmp/sockets/puma.sock/", host: "beta.vellum.co.ke"
2019/04/25 13:28:43 [error] 16613#16613: *5 upstream timed out (110: Connection timed out) while reading response header from upstream, client: 162.158.42.36, server: beta.vellum.co.ke, request: "GET / HTTP/1.1", upstream: "http://unix:/var/www/vellum/shared/tmp/sockets/puma.sock/", host: "beta.vellum.co.ke"
ruslan-nazarets commented 5 years ago

Probably related to #1905

github-actions[bot] commented 3 years ago

Stale issue message