Giter Club home page Giter Club logo

capistrano-puma's Introduction

Gem Version

Capistrano::Puma

Installation

Add this line to your application's Gemfile:

gem 'capistrano3-puma', github: "seuros/capistrano-puma"

or:

gem 'capistrano3-puma' , group: :development

And then execute:

$ bundle

Usage

    # Capfile

    require 'capistrano/puma'
    install_plugin Capistrano::Puma  # Default puma tasks
    install_plugin Capistrano::Puma::Systemd

To prevent loading the hooks of the plugin, add false to the load_hooks param.

    # Capfile

    install_plugin Capistrano::Puma, load_hooks: false  # Default puma tasks without hooks

To make it work with rvm, rbenv and chruby, install the plugin after corresponding library inclusion.

    # Capfile

    require 'capistrano/rbenv'
    require 'capistrano/puma'
    install_plugin Capistrano::Puma

Config

Puma configuration is expected to be in config/puma.rb or config/puma/#{fetch(:puma_env)}.rb and checked in your repository. Uploading the configuration via capistrano was removed as it was causing problems with custom configurations.

Example

A sample application is provided to show how to use this gem at https://github.com/seuros/capistrano-example-app

Systemd Socket Activation

Systemd socket activation starts your app upon first request if it is not already running

    set :puma_enable_socket_service, true

For more information on socket activation have a look at the systemd.socket man page.

To restart the listening socket using Systemd run

cap puma:systemd:restart_socket

This would also restart the puma instance as the puma service depends on the socket service being active

Other configs

Configurable options, shown here with defaults: Please note the configuration options below are not required unless you are trying to override a default setting, for instance if you are deploying on a host on which you do not have sudo or root privileges and you need to restrict the path. These settings go in the deploy.rb file.

    set :puma_user, fetch(:user)
    set :puma_role, :web
    set :puma_service_unit_env_files, []
    set :puma_service_unit_env_vars, []

Notes: If you are setting values for variables that might be used by other plugins, use append instead of set. For example:

append :rbenv_map_bins, 'puma', 'pumactl'

Nginx documentation

Nginx documentation was moved to nginx.md

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request

capistrano-puma's People

Contributors

bendilley avatar crhan avatar crohr avatar dfang avatar eric-guo avatar hbin avatar hnatt avatar itsnikolay avatar ivanovaleksey avatar linjunpop avatar lonre avatar marcoschicote avatar mcelicalderon avatar mdesanti avatar molfar avatar neolyte avatar notapatch avatar paulomcnally avatar peterkarnov avatar petertoth avatar phylor avatar rafaelgoulart avatar rhannequin avatar rojosinalma avatar seuros avatar sime avatar snoozer05 avatar soylent avatar stefanwild avatar w-leads avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

capistrano-puma's Issues

Puma nginx requires role

By default, nginx_config will be executed with :web role. But you can assign it to a different role

Not true.

:puma_nginx role not set!
/Users/jancel/.rvm/gems/ruby-2.1.2@xfit/gems/capistrano3-puma-0.8.1/lib/capistrano/tasks/nginx.cap:10:in `block (2 levels) in <top (required)>'
/Users/jancel/.rvm/gems/ruby-2.1.2@xfit/gems/capistrano-3.2.1/lib/capistrano/application.rb:15:in `run'
/Users/jancel/.rvm/gems/ruby-2.1.2@xfit/gems/capistrano-3.2.1/bin/cap:3:in `<top (required)>'
/Users/jancel/.rvm/gems/ruby-2.1.2@xfit/bin/cap:23:in `load'
/Users/jancel/.rvm/gems/ruby-2.1.2@xfit/bin/cap:23:in `<main>'
/Users/jancel/.rvm/gems/ruby-2.1.2@xfit/bin/ruby_executable_hooks:15:in `eval'
/Users/jancel/.rvm/gems/ruby-2.1.2@xfit/bin/ruby_executable_hooks:15:in `<main>'

Could not locate Gemfile for puma:restart

 INFO [aa5b15dd] Running bundle exec puma -C /var/www/msp3/shared/config/puma.rb on dev01.nms.local
DEBUG [aa5b15dd] Command: bundle exec puma -C /var/www/msp3/shared/config/puma.rb
DEBUG [aa5b15dd]    Could not locate Gemfile
cap aborted!
bundle exec puma -C /var/www/msp3/shared/config/puma.rb stdout: Nothing written
bundle exec puma -C /var/www/msp3/shared/config/puma.rb stderr: Nothing written

It should prepand "cd #{current_path}" for the command bundle exec puma

First deploy fails when using this gem

Background:
My app must be deployable to a blank machine instance and run immediately, i.e. the first time the app is deployed.

When I use this gem for a first deploy the deploy fails due to the state file not existing during the after :finished, 'puma:restart' task.

What Should Happen (according to the instructions in the README file)

  1. Run cap production deploy
  2. My code is deployed, the puma.rb config file is created, and puma is started

What Actually Happens:

  1. cap production deploy fails on Running /usr/bin/env bundle exec pumactl -S /webapps/c3-puma-test/shared/tmp/pids/puma.state restart

There are further issues when this is fixed manually, but the point is that there should be no manual intervention needed.
The instructions are very unclear as to what is needed (e.g. shared directories, files, etc) and the tasks such as puma:config and puma:start are not automatically run on first deploy.
If I use this gem then I cannot simply run cap production deploy at all on a new machine.

I have created a small PoC app to show exactly what I mean. You can find the code and instructions to replicate this bug here: https://github.com/shaneog/c3-puma-test

Problem with uploading puma.rb using puma:config command

I created my own puma.rb before to be used with foreman but then I stumbled to this gem and realized that it will be easier and organized for me to use this. I've been trying to find a solution for this problem but no one seems to have encountered it yet besides me. When I run cap production puma:config I always end up with this error:

Uploading /app/shared/config/puma.rb 0.0%
cap aborted!
SSHKit::Runner::ExecuteError: Exception while executing on host ec2-vps.com: >�scp:
/app/shared/config/puma.rb: No such file or directory

Please note on the last line that s is displayed in a unicode character. Like this: scp, but I don't think it's the problem.
The same issue occurs when I try to deploy my app using cap production deploy. And just to clear things up, I assume that the puma:config command uploads puma.rb base on the settings I specified in deploy.rb or do I have to make my own puma.rb on my VPS?

Thanks. Your answer will be appreciated.

Add Inspeqtor support

It would be great to see capistrano-puma trigger Inspeqtor's deploy window during deploys, a la capistrano-sidekiq.

preload_app! and phased restart

Hi,

I was finding out why phased restart doesn't work for me and the reason was preload_app! option in the puma.rb config which was generated by this great gem. I'm missing this fact in puma docs so here (as related to deploying) - it could be helpful for others.

So I just vote for being able to set preload_app! via capistrano recipe too and mention the relation with phased restart in readme doc. Please enlighten me if I'm missing something or I don't understand the benefit of preload_app! over the phased restart. Thank you.

Release a 0.7.1 with the latest fix

the nginx.cap file is broken, you fixed it last month but the gem is stale.

On the other hand, would be possible to put the sudo options you have to move and link the file there optional? My deploy user doesn't have sudo powers.

Wrong puma dependency

Puma downgrade from version 2.8.x to 0.9.5 If we use "spec.add_dependency 'puma' , '~> 0'" in capistrano3-puma.gemspec

bash: /bin/rvm: No such file or directory

When running cap production rvm:check I get no errors and the output

DEBUG [138bf764] Running /var/www/skateboxes/.rvm/bin/rvm current on 162.243.33.179
DEBUG [138bf764] Command: ( RVM_BIN_PATH=~/.rvm/bin RAILS_ENV=production /var/www/skateboxes/.rvm/bin/rvm current )
DEBUG [138bf764]    ruby-2.0.0-p247
DEBUG [138bf764] Finished in 1.174 seconds with exit status 0 (successful).
DEBUG [a99164dc] Running /var/www/skateboxes/.rvm/bin/rvm version on 162.243.33.179
DEBUG [a99164dc] Command: ( RVM_BIN_PATH=~/.rvm/bin RAILS_ENV=production /var/www/skateboxes/.rvm/bin/rvm version )
DEBUG [a99164dc]
DEBUG [a99164dc]    rvm 1.24.1 (stable) by Wayne E. Seguin <[email protected]>, Michal Papis <[email protected]> [https://rvm.io/]
DEBUG [a99164dc]
DEBUG [a99164dc] Finished in 0.843 seconds with exit status 0 (successful).
rvm 1.24.1 (stable) by Wayne E. Seguin <[email protected]>, Michal Papis <[email protected]> [https://rvm.io/]
DEBUG [e0f89017] Running /var/www/skateboxes/.rvm/bin/rvm current on 162.243.33.179
DEBUG [e0f89017] Command: ( RVM_BIN_PATH=~/.rvm/bin RAILS_ENV=production /var/www/skateboxes/.rvm/bin/rvm current )
DEBUG [e0f89017]    ruby-2.0.0-p247
DEBUG [e0f89017] Finished in 0.357 seconds with exit status 0 (successful).
ruby-2.0.0-p247
DEBUG [dc326b3f] Running /var/www/skateboxes/.rvm/bin/rvm ruby-2.0.0-p247 do ruby --version on 162.243.33.179
DEBUG [dc326b3f] Command: ( RVM_BIN_PATH=~/.rvm/bin RAILS_ENV=production /var/www/skateboxes/.rvm/bin/rvm ruby-2.0.0-p247 do ruby --version )
DEBUG [dc326b3f]    ruby 2.0.0p247 (2013-06-27 revision 41674) [x86_64-linux]
DEBUG [dc326b3f] Finished in 0.866 seconds with exit status 0 (successful).
ruby 2.0.0p247 (2013-06-27 revision 41674) [x86_64-linux]

When running cap production puma:status (or any other puma task for that matter) I get

DEBUG [903e5133] Running if test ! -d /var/www/skateboxes/current; then echo "Directory does not exist '/var/www/skateboxes/current'" 1>&2; false; fi on 162.243.33.179
DEBUG [903e5133] Command: if test ! -d /var/www/skateboxes/current; then echo "Directory does not exist '/var/www/skateboxes/current'" 1>&2; false; fi
DEBUG [903e5133] Finished in 0.520 seconds with exit status 0 (successful).
 INFO [c85a5496] Running /bin/rvm  do pumactl -S /var/www/skateboxes/shared/tmp/pids/puma.state status on 162.243.33.179
DEBUG [c85a5496] Command: cd /var/www/skateboxes/current && ( RVM_BIN_PATH=~/.rvm/bin RAILS_ENV=production /bin/rvm  do pumactl -S /var/www/skateboxes/shared/tmp/pids/puma.state status )
DEBUG [c85a5496]    bash: /bin/rvm: No such file or directory

The interesting part here is that in the rvm:check command it knew to run .../var/www/skateboxes/.rvm/bin/rvm ruby-2.0.0-p247 do... whereas puma:status simply tried to run .../bin/rvm...;

Defaults Overriding Custom Settings

This is my first puma setup, so I'm really sorry if I'm on the wrong track here. I have created a config/puma.rb file which binds like bind 'tcp://0.0.0.0:9292'. But it is ignored. So, then, I thought, "maybe I need to override it in capistrano-puma", and I added the line set :puma_bind, "tcp://0.0.0.0:9292" to my config/deploy.rb file. In either case, you can see puma is still binding to the default setting for some reason.

Any other details I can provide? Thanks so much :)

Puma starting in single mode...
* Version 2.8.2 (ruby 2.1.1-p76), codename: Sir Edmund Percival Hillary
* Min threads: 0, max threads: 16
* Environment: production
* Listening on unix:/var/www/myapp/shared/tmp/sockets/puma.sock
* Daemonizing...

Just in case they're important, details:
OS: Ubuntu 14.04
Rails: 4.1.0

Won't start in production mode

DEBUG [bd58f56e] Command: cd /home/deploy/nutrition_app/current && ( PATH=/usr/local/ruby-2.1.0/bin:/usr/local/node-v0.10.24/bin:$PATH RAILS_ENV=production /usr/bin/env bundle exec puma -C /home/deploy/nutrition_app/current/config/puma.rb )

DEBUG [bd58f56e]    [1766] Puma starting in cluster mode...
DEBUG [bd58f56e]
DEBUG [bd58f56e]    [1766] * Version 2.4.0, codename: Crunchy Munchy Lunchy
DEBUG [bd58f56e]
DEBUG [bd58f56e]    [1766] * Min threads: 8, max threads: 16
DEBUG [bd58f56e]
DEBUG [bd58f56e]    [1766] * Environment: development

I have not set :puma_env in deploy.rb. puts fetch(:puma_env) returns production.

My Gemfile:

  gem "capistrano"
  gem "capistrano3-puma", github: "seuros/capistrano-puma"
  gem "capistrano-rails"

I'm using Capistrano 3.1.

Thanks for the help.

cap production puma:deploy hangs

When running cap production puma:start the process just seems to hang there without finishing

DEBUG [adac9a58]    Puma starting in single mode...
DEBUG [adac9a58]    * Version 2.6.0, codename: Pantsuit Party
DEBUG [adac9a58]    * Min threads: 0, max threads: 16
DEBUG [adac9a58]    * Environment: production

The app is not accessible via the browser

set :puma_bind, "tcp://0.0.0.0:3000" Not working

set :puma_bind, "tcp://0.0.0.0:3000" Not working I have the TCP address set to my servers address not 0.0.0.0 I have tried the too but puma start always reports

  • Listening on unix:/apps/staging-webflex-kitting/shared/tmp/sockets/puma.sock

Status file not found

I have deployed my application and it worked once, but again when I tried to deploy it again I received following error:

DEBUG[a90fa6f0] Command: cd /var/www/apps/blazarsol/releases/20141126143552 && /usr/bin/env bundle exec pumactl -S /var/www/apps/blazarsol/shared/tmp/pids/puma.state restart
DEBUG[a90fa6f0] Status file not found: /var/www/apps/blazarsol/shared/tmp/pids/puma.state
DEBUG[a90fa6f0]
cap aborted!
SSHKit::Runner::ExecuteError: Exception while executing on host 54.169.166.162: Exception while executing on host 54.169.166.162: bundle exit status: 1
bundle stdout: Nothing written
bundle stderr: Nothing written

prune_bundler option to be default

Hi,

I've experienced a situation where Puma hadn't picked up newly installed gems post deployment. I don't pretend I completely understand the problem, but the following discussion suggests using prune_bundler in Puma config.

puma/puma#416

Unable to use w/ capistrano (3.1.0)

When attempting to do a bundle update I receive

Bundler could not find compatible versions for gem "capistrano":
  In Gemfile:
    capistrano-puma (>= 0) ruby depends on
      capistrano (~> 3.0.0) ruby

    capistrano (3.1.0)

puma monit config can not start with production and rbenv tips

Update:

Fix not start with production.

add RACK_ENV to /etc/environment

RAILS_ENV=production
RACK_ENV=production

rbenv tips

set :rbenv_type, :system
set :rbenv_ruby, '2.1.2'
set :rbenv_path, '/var/opt/rbenv'
set :rbenv_prefix, "RBENV_ROOT=#{fetch(:rbenv_path)} RBENV_VERSION=#{fetch(:rbenv_ruby)} #{fetch(:rbenv_path)}/bin/rbenv exec"

But still not work fine. It running, but production env has some problem, make errors in production.log.

I will go on find, how to fix.

capistrano 3 / puma error: pumactl: command not found

Hello

I have a problem when run:

cap sandbox puma:status
DEBUG [2aafcc53] Running if test ! -d /var/www/apps/project/sandbox/current; then echo "Directory does not exist '/var/www/apps/project/sandbox/current'" 1>&2; false; fi on fb.by
DEBUG [2aafcc53] Command: if test ! -d /var/www/apps/project/sandbox/current; then echo "Directory does not exist '/var/www/apps/project/sandbox/current'" 1>&2; false; fi
DEBUG [2aafcc53] Finished in 0.622 seconds with exit status 0 (successful).
 INFO [410239c4] Running pumactl -S /var/www/apps/project/sandbox/shared/tmp/pids/puma.state status on fb.by
DEBUG [410239c4] Command: cd /var/www/apps/project/sandbox/current && pumactl -S /var/www/apps/project/sandbox/shared/tmp/pids/puma.state status
DEBUG [410239c4]  bash: pumactl: command not found
cap aborted!
pumactl stdout: Nothing written
pumactl stderr: Nothing written

Capfile

# Load DSL and Setup Up Stages
require 'capistrano/setup'

# Includes default deployment tasks
require 'capistrano/deploy'
require 'capistrano/bundler' # Rails needs Bundler, right?
require 'capistrano/rails/assets'
require 'capistrano/rails/migrations'
require 'capistrano/puma'

require 'rvm1/capistrano3'
require 'capistrano/rvm'

# Loads custom tasks from `lib/capistrano/tasks' if you have any defined.
Dir.glob('lib/capistrano/tasks/*.cap').each { |r| import r }
cap sandbox deploy

works fine

Are there any ideas?
Thanks.

No such file or directory - bind(2) (Errno::ENOENT)

Hope you might be able to help me. I've added gem 'capistrano3-puma', require: false to my Gemfile and the require 'capistrano/puma' line to my Capfile.

But when I deploy or run cap production puma:start I get the following output. Am I missing something?

DEBUG[fb264c29]   Puma starting in single mode...
DEBUG[fb264c29]   * Version 2.9.0 (rbx 2.1.0), codename: Team High Five
DEBUG[fb264c29]   * Min threads: 0, max threads: 16
DEBUG[fb264c29]   * Environment: production
DEBUG[fb264c29]   * Listening on unix:/home/deployer/public_html/app_name/shared/tmp/sockets/puma.sock
DEBUG[fb264c29]   
DEBUG[fb264c29]   An exception occurred running /home/deployer/public_html/app_name/shared/bundle/rbx/2.1/bin/puma:
DEBUG[fb264c29]   
DEBUG[fb264c29]   
DEBUG[fb264c29]       No such file or directory - bind(2) (Errno::ENOENT)
DEBUG[fb264c29]   
DEBUG[fb264c29]   
DEBUG[fb264c29]   Backtrace:
DEBUG[fb264c29]   
DEBUG[fb264c29]   
DEBUG[fb264c29]   [0;31m                          Errno.handle at kernel/common/errno.rb:17[0m
DEBUG[fb264c29]   
DEBUG[fb264c29]       UNIXSocket(UNIXServer)#unix_setup at /opt/rubies/rubinius-2.2.10/gems/gems
DEBUG[fb264c29]   
DEBUG[fb264c29]                                            /rubysl-socket-2.0.1/lib/rubysl
DEBUG[fb264c29]   
DEBUG[fb264c29]                                            /socket.rb:1164[0m
DEBUG[fb264c29]   
DEBUG[fb264c29]                   UNIXServer#initialize at /opt/rubies/rubinius-2.2.10/gems/gems
DEBUG[fb264c29]   
DEBUG[fb264c29]                                            /rubysl-socket-2.0.1/lib/rubysl
DEBUG[fb264c29]   
DEBUG[fb264c29]                                            /socket.rb:1225[0m
DEBUG[fb264c29]   
DEBUG[fb264c29]          Puma::Binder#add_unix_listener at /home/deployer/public_html/app_name
DEBUG[fb264c29]   
DEBUG[fb264c29]                                            /shared/bundle/rbx/2.1/gems/puma-2.9.0
DEBUG[fb264c29]   
DEBUG[fb264c29]                                            /lib/puma/binder.rb:275[0m
DEBUG[fb264c29]   
DEBUG[fb264c29]               { } in Puma::Binder#parse at /home/deployer/public_html/app_name
DEBUG[fb264c29]   
DEBUG[fb264c29]                                            /shared/bundle/rbx/2.1/gems/puma-2.9.0
DEBUG[fb264c29]   
DEBUG[fb264c29]                                            /lib/puma/binder.rb:119[0m
DEBUG[fb264c29]   
DEBUG[fb264c29]   [0;34m                            Array#each at kernel/bootstrap/array.rb:76[0m
DEBUG[fb264c29]   
DEBUG[fb264c29]                      Puma::Binder#parse at /home/deployer/public_html/app_name
DEBUG[fb264c29]   
DEBUG[fb264c29]                                            /shared/bundle/rbx/2.1/gems/puma-2.9.0
DEBUG[fb264c29]   
DEBUG[fb264c29]                                            /lib/puma/binder.rb:82[0m
DEBUG[fb264c29]   
DEBUG[fb264c29]    Puma::Runner(Puma::Single)#load_and_bind at /home/deployer/public_html/app_name
DEBUG[fb264c29]   
DEBUG[fb264c29]                                                /shared/bundle/rbx/2.1/gems
DEBUG[fb264c29]   
DEBUG[fb264c29]                                                /puma-2.9.0/lib/puma/runner.rb:119[0m
DEBUG[fb264c29]   
DEBUG[fb264c29]                        Puma::Single#run at /home/deployer/public_html/app_name
DEBUG[fb264c29]   
DEBUG[fb264c29]                                            /shared/bundle/rbx/2.1/gems/puma-2.9.0
DEBUG[fb264c29]   
DEBUG[fb264c29]                                            /lib/puma/single.rb:73[0m
DEBUG[fb264c29]   
DEBUG[fb264c29]                           Puma::CLI#run at /home/deployer/public_html/app_name
DEBUG[fb264c29]   
DEBUG[fb264c29]                                            /shared/bundle/rbx/2.1/gems/puma-2.9.0
DEBUG[fb264c29]   
DEBUG[fb264c29]                                            /lib/puma/cli.rb:499[0m
DEBUG[fb264c29]   
DEBUG[fb264c29]                       Object#__script__ at /home/deployer/public_html/app_name
DEBUG[fb264c29]   
DEBUG[fb264c29]                                      
DEBUG[fb264c29]         /shared/bundle/rbx/2.1/gems/puma-2.9.0
DEBUG[fb264c29]   
DEBUG[fb264c29]                                            /bin/puma:10[0m
DEBUG[fb264c29]   
DEBUG[fb264c29]   [0;34m                   Kernel(Object)#load at kernel/common/kernel.rb:447[0m
DEBUG[fb264c29]   
DEBUG[fb264c29]                       Object#__script__ at /home/deployer/public_html/app_name
DEBUG[fb264c29]   
DEBUG[fb264c29]                                            /shared/bundle/rbx/2.1/bin/puma:23[0m
DEBUG[fb264c29]   
DEBUG[fb264c29]   [0;34m      Rubinius::CodeLoader#load_script at kernel/delta/code_loader.rb:66[0m
DEBUG[fb264c29]   
DEBUG[fb264c29]   [0;34m      Rubinius::CodeLoader.load_script at kernel/delta/code_loader.rb:152[0m
DEBUG[fb264c29]   
DEBUG[fb264c29]   [0;34m               Rubinius::Loader#script at kernel/loader.rb:649[0m
DEBUG[fb264c29]   
DEBUG[fb264c29]   [0;34m                 Rubinius::Loader#main at kernel/loader.rb:825[0m
DEBUG[fb264c29]   
cap aborted!
SSHKit::Runner::ExecuteError: Exception while executing on host app_name-beta: bundle exit status: 1
bundle stdout: Nothing written
bundle stderr: Nothing written

For reference here's my Gemfile: https://gist.github.com/asgerb/c1622d29fe7ad8e55064
And my Capfile: https://gist.github.com/asgerb/e92f5ded1951da732e31

when i run 'cap production deploy', i get this error!

Command: cd /home/stephen/www/mywy/current && ( RBENV_ROOT=~/.rbenv RBENV_VERSION=2.1.0-rc1 RBENV_ROOT=~/.rbenv RBENV_VERSION=2.1.0-rc1 ~/.rbenv/bin/rbenv exec bundle exec puma -C /home/stephen/www/mywy/shared/puma.rb )
DEBUG [685f852f]    Puma starting in single mode...
DEBUG [685f852f]    * Version 2.6.0, codename: Pantsuit Party
DEBUG [685f852f]    * Min threads: 0, max threads: 16
DEBUG [685f852f]    * Environment: production
DEBUG [685f852f]    * Listening on unix:/home/stephen/www/mywy/shared/tmp/sockets/puma.sock
DEBUG [685f852f]    * Listening on unix:/home/stephen/www/mywy/shared/tmp/sockets/puma.sock
DEBUG [685f852f]    /home/stephen/www/mywy/shared/bundle/ruby/2.1.0/gems/puma-2.6.0/lib/puma/binder.rb:270:in `initialize': No such file or directory - connect(2) for "/home/stephen/www/mywy/shared/tmp/sockets/puma.sock" (Errno::ENOENT)
DEBUG [685f852f]        from /home/stephen/www/mywy/shared/bundle/ruby/2.1.0/gems/puma-2.6.0/lib/puma/binder.rb:270:in `new'
DEBUG [685f852f]        from /home/stephen/www/mywy/shared/bundle/ruby/2.1.0/gems/puma-2.6.0/lib/puma/binder.rb:270:in `add_unix_listener'
DEBUG [685f852f]        from /home/stephen/www/mywy/shared/bundle/ruby/2.1.0/gems/puma-2.6.0/lib/puma/binder.rb:114:in `block in parse'
DEBUG [685f852f]    * Listening on unix:/home/stephen/www/mywy/shared/tmp/sockets/puma.sock
DEBUG [685f852f]        from /home/stephen/www/mywy/shared/bundle/ruby/2.1.0/gems/puma-2.6.0/lib/puma/binder.rb:82:in `each'
DEBUG [685f852f]        from /home/stephen/www/mywy/shared/bundle/ruby/2.1.0/gems/puma-2.6.0/lib/puma/binder.rb:82:in `parse'
DEBUG [685f852f]        from /home/stephen/www/mywy/shared/bundle/ruby/2.1.0/gems/puma-2.6.0/lib/puma/runner.rb:111:in `load_and_bind'
DEBUG [685f852f]        from /home/stephen/www/mywy/shared/bundle/ruby/2.1.0/gems/puma-2.6.0/lib/puma/single.rb:73:in `run'
DEBUG [685f852f]        from /home/stephen/www/mywy/shared/bundle/ruby/2.1.0/gems/puma-2.6.0/lib/puma/cli.rb:442:in `run'
DEBUG [685f852f]        from /home/stephen/www/mywy/shared/bundle/ruby/2.1.0/gems/puma-2.6.0/bin/puma:10:in `<top (required)>'
DEBUG [685f852f]        from /home/stephen/www/mywy/shared/bundle/ruby/2.1.0/bin/puma:23:in `load'
DEBUG [685f852f]        from /home/stephen/www/mywy/shared/bundle/ruby/2.1.0/bin/puma:23:in `<main>'
cap aborted!
bundle stdout: Nothing written
bundle stderr: Nothing written

Tasks: TOP => puma:restart
(See full trace by running task with --trace)
The deploy has failed with an error: #<SSHKit::Command::Failed: bundle stdout: Nothing written
bundle stderr: Nothing written

my cap file

# Load DSL and Setup Up Stages
require 'capistrano/setup'

# Includes default deployment tasks
require 'capistrano/deploy'
# Includes tasks from other gems included in your Gemfile
#
# For documentation on these, see for example:
#
#   https://github.com/capistrano/rvm
#   https://github.com/capistrano/rbenv
#   https://github.com/capistrano/chruby
#   https://github.com/capistrano/bundler
#   https://github.com/capistrano/rails
#
# require 'capistrano/rvm'
require 'capistrano/rbenv'
require 'capistrano/puma'
# require 'capistrano/chruby'
require 'capistrano/bundler'
require 'capistrano/rails/assets'
require 'capistrano/rails/migrations'

# Loads custom tasks from `lib/capistrano/tasks' if you have any defined.
Dir.glob('lib/capistrano/tasks/*.cap').each { |r| import r }

my deploy file

# config valid only for Capistrano 3.1
lock '3.1.0'

set :application, 'mywy'
set :repo_url, '[email protected]:85636682/mywy.git'

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

# Default deploy_to directory is /var/www/my_app
set :deploy_to, "/home/stephen/www/mywy"

# Default value for :scm is :git
# set :scm, :git

# Default value for :format is :pretty
# set :format, :pretty

# Default value for :log_level is :debug
# set :log_level, :debug

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

# Default value for :linked_files is []
# set :linked_files, %w{config/database.yml}

# Default value for linked_dirs is []
# set :linked_dirs, %w{bin log tmp/pids tmp/cache tmp/sockets vendor/bundle public/system}

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

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

set :rbenv_type, :user # or :system, depends on your rbenv setup
set :rbenv_ruby_version, '2.1.0-rc1'
set :rbenv_ruby, '2.1.0-rc1'
set :rbenv_prefix, "RBENV_ROOT=#{fetch(:rbenv_path)} RBENV_VERSION=#{fetch(:rbenv_ruby)} #{fetch(:rbenv_path)}/bin/rbenv exec"
set :rbenv_map_bins, %w{rake gem bundle ruby rails}
set :rbenv_roles, :all # default value

set :puma_state, "#{shared_path}/tmp/pids/puma.state"
set :puma_pid, "#{shared_path}/tmp/pids/puma.pid"
set :puma_bind, "unix://#{shared_path}/tmp/sockets/puma.sock"
set :puma_conf, "#{shared_path}/puma.rb"
set :puma_access_log, "#{shared_path}/log/puma_error.log"
set :puma_error_log, "#{shared_path}/log/puma_access.log"
set :puma_role, :app
set :puma_env, fetch(:rack_env, fetch(:rails_env, 'production'))
set :puma_threads, [0, 16]
set :puma_workers, 0
set :puma_init_active_record, false

namespace :deploy do

  desc 'Restart application'
  task :restart do
    on roles(:app), in: :sequence, wait: 5 do
      # Your restart mechanism here, for example:
      # execute :touch, release_path.join('tmp/restart.txt')
    end
  end

  after :publishing, :restart

  after :restart, :clear_cache do
    on roles(:web), in: :groups, limit: 3, wait: 10 do
      # Here we can do anything such as:
      # within release_path do
      #   execute :rake, 'cache:clear'
      # end
    end
  end

end

please help me!thanks!

puma_env inconsistent with rails_env (from capistrano/rails)

Defaults for puma_env and rails_env appear to be a bit different. While capistrano-puma assumes that when no environment has been defined the default is production. The rails module assumes that the default env is the same as the current stage.

While this is a minor inconvenience, it can wreak havoc on staging environments which might assume that the target it production and not staging (if the user assumes the same behavior as rails module).

No such file or directory - "[APP_PATH]shared/tmp/puma/sock"

I have installed the gem, added require "capistrano/puma" to my Capfile and ran cap production puma:config but when I run cap production puma:start but am getting the following output. Is there an additional step that I'm missing?

 INFO [bea3709a] Running cd /var/www/skateboxes/current && bundle exec puma -C /var/www/skateboxes/shared/config/puma.rb on [Host]
DEBUG [bea3709a] Command: cd /var/www/skateboxes/current && bundle exec puma -C /var/www/skateboxes/shared/config/puma.rb
DEBUG [bea3709a]    Puma starting in single mode...
DEBUG [bea3709a]
DEBUG [bea3709a]    * Version 2.6.0, codename: Pantsuit Party
DEBUG [bea3709a]
DEBUG [bea3709a]    * Min threads: 0, max threads: 16
DEBUG [bea3709a]
DEBUG [bea3709a]    * Environment: production
DEBUG [bea3709a]
DEBUG [bea3709a]    * Listening on unix:///var/www/skateboxes/shared/tmp/puma/sock
DEBUG [bea3709a]
DEBUG [bea3709a]
DEBUG [bea3709a]    /var/www/skateboxes/shared/bundle/ruby/2.0.0/gems/puma-2.6.0/lib/puma/binder.rb:270:in `initialize'
DEBUG [bea3709a]
DEBUG [bea3709a]    :
DEBUG [bea3709a]
DEBUG [bea3709a]    No such file or directory - "/var/www/skateboxes/shared/tmp/puma/sock"
DEBUG [bea3709a]
DEBUG [bea3709a]     (
DEBUG [bea3709a]
DEBUG [bea3709a]    Errno::ENOENT
DEBUG [bea3709a]
DEBUG [bea3709a]    )
DEBUG [bea3709a]
DEBUG [bea3709a]        from /var/www/skateboxes/shared/bundle/ruby/2.0.0/gems/puma-2.6.0/lib/puma/binder.rb:270:in `new'
DEBUG [bea3709a]
DEBUG [bea3709a]        from /var/www/skateboxes/shared/bundle/ruby/2.0.0/gems/puma-2.6.0/lib/puma/binder.rb:270:in `add_unix_listener'
DEBUG [bea3709a]
DEBUG [bea3709a]        from /var/www/skateboxes/shared/bundle/ruby/2.0.0/gems/puma-2.6.0/lib/puma/binder.rb:114:in `block in parse'
DEBUG [bea3709a]
DEBUG [bea3709a]        from /var/www/skateboxes/shared/bundle/ruby/2.0.0/gems/puma-2.6.0/lib/puma/binder.rb:82:in `each'
DEBUG [bea3709a]
DEBUG [bea3709a]        from /var/www/skateboxes/shared/bundle/ruby/2.0.0/gems/puma-2.6.0/lib/puma/binder.rb:82:in `parse'
DEBUG [bea3709a]
DEBUG [bea3709a]        from /var/www/skateboxes/shared/bundle/ruby/2.0.0/gems/puma-2.6.0/lib/puma/runner.rb:111:in `load_and_bind'
DEBUG [bea3709a]
DEBUG [bea3709a]        from /var/www/skateboxes/shared/bundle/ruby/2.0.0/gems/puma-2.6.0/lib/puma/single.rb:73:in `run'
DEBUG [bea3709a]
DEBUG [bea3709a]        from /var/www/skateboxes/shared/bundle/ruby/2.0.0/gems/puma-2.6.0/lib/puma/cli.rb:442:in `run'
DEBUG [bea3709a]
DEBUG [bea3709a]        from /var/www/skateboxes/shared/bundle/ruby/2.0.0/gems/puma-2.6.0/bin/puma:10:in `<top (required)>'
DEBUG [bea3709a]
DEBUG [bea3709a]        from /var/www/skateboxes/shared/bundle/ruby/2.0.0/bin/puma:23:in `load'
DEBUG [bea3709a]
DEBUG [bea3709a]        from /var/www/skateboxes/shared/bundle/ruby/2.0.0/bin/puma:23:in `<main>'
cap aborted!
cd /var/www/skateboxes/current && bundle exec puma -C /var/www/skateboxes/shared/config/puma.rb stdout: Nothing written
cd /var/www/skateboxes/current && bundle exec puma -C /var/www/skateboxes/shared/config/puma.rb stderr: Nothing written
/Users/kyledecot/.rvm/gems/ruby-2.0.0-p247@skateboxes/gems/sshkit-1.1.0/lib/sshkit/command.rb:94:in `exit_status='
/Users/kyledecot/.rvm/gems/ruby-2.0.0-p247@skateboxes/gems/sshkit-1.1.0/lib/sshkit/backends/netssh.rb:125:in `block (4 levels) in _execute'
/Users/kyledecot/.rvm/gems/ruby-2.0.0-p247@skateboxes/gems/net-ssh-2.7.0/lib/net/ssh/connection/channel.rb:551:in `call'
/Users/kyledecot/.rvm/gems/ruby-2.0.0-p247@skateboxes/gems/net-ssh-2.7.0/lib/net/ssh/connection/channel.rb:551:in `do_request'
/Users/kyledecot/.rvm/gems/ruby-2.0.0-p247@skateboxes/gems/net-ssh-2.7.0/lib/net/ssh/connection/session.rb:561:in `channel_request'
/Users/kyledecot/.rvm/gems/ruby-2.0.0-p247@skateboxes/gems/net-ssh-2.7.0/lib/net/ssh/connection/session.rb:465:in `dispatch_incoming_packets'
/Users/kyledecot/.rvm/gems/ruby-2.0.0-p247@skateboxes/gems/net-ssh-2.7.0/lib/net/ssh/connection/session.rb:221:in `preprocess'
/Users/kyledecot/.rvm/gems/ruby-2.0.0-p247@skateboxes/gems/net-ssh-2.7.0/lib/net/ssh/connection/session.rb:205:in `process'
/Users/kyledecot/.rvm/gems/ruby-2.0.0-p247@skateboxes/gems/net-ssh-2.7.0/lib/net/ssh/connection/session.rb:169:in `block in loop'
/Users/kyledecot/.rvm/gems/ruby-2.0.0-p247@skateboxes/gems/net-ssh-2.7.0/lib/net/ssh/connection/session.rb:169:in `loop'
/Users/kyledecot/.rvm/gems/ruby-2.0.0-p247@skateboxes/gems/net-ssh-2.7.0/lib/net/ssh/connection/session.rb:169:in `loop'
/Users/kyledecot/.rvm/gems/ruby-2.0.0-p247@skateboxes/gems/net-ssh-2.7.0/lib/net/ssh/connection/channel.rb:269:in `wait'
/Users/kyledecot/.rvm/gems/ruby-2.0.0-p247@skateboxes/gems/sshkit-1.1.0/lib/sshkit/backends/netssh.rb:147:in `block (2 levels) in _execute'
/Users/kyledecot/.rvm/gems/ruby-2.0.0-p247@skateboxes/gems/net-ssh-2.7.0/lib/net/ssh/connection/channel.rb:514:in `call'
/Users/kyledecot/.rvm/gems/ruby-2.0.0-p247@skateboxes/gems/net-ssh-2.7.0/lib/net/ssh/connection/channel.rb:514:in `do_open_confirmation'
/Users/kyledecot/.rvm/gems/ruby-2.0.0-p247@skateboxes/gems/net-ssh-2.7.0/lib/net/ssh/connection/session.rb:545:in `channel_open_confirmation'
/Users/kyledecot/.rvm/gems/ruby-2.0.0-p247@skateboxes/gems/net-ssh-2.7.0/lib/net/ssh/connection/session.rb:465:in `dispatch_incoming_packets'
/Users/kyledecot/.rvm/gems/ruby-2.0.0-p247@skateboxes/gems/net-ssh-2.7.0/lib/net/ssh/connection/session.rb:221:in `preprocess'
/Users/kyledecot/.rvm/gems/ruby-2.0.0-p247@skateboxes/gems/net-ssh-2.7.0/lib/net/ssh/connection/session.rb:205:in `process'
/Users/kyledecot/.rvm/gems/ruby-2.0.0-p247@skateboxes/gems/net-ssh-2.7.0/lib/net/ssh/connection/session.rb:169:in `block in loop'
/Users/kyledecot/.rvm/gems/ruby-2.0.0-p247@skateboxes/gems/net-ssh-2.7.0/lib/net/ssh/connection/session.rb:169:in `loop'
/Users/kyledecot/.rvm/gems/ruby-2.0.0-p247@skateboxes/gems/net-ssh-2.7.0/lib/net/ssh/connection/session.rb:169:in `loop'
/Users/kyledecot/.rvm/gems/ruby-2.0.0-p247@skateboxes/gems/sshkit-1.1.0/lib/sshkit/backends/netssh.rb:149:in `block in _execute'
/Users/kyledecot/.rvm/gems/ruby-2.0.0-p247@skateboxes/gems/sshkit-1.1.0/lib/sshkit/backends/netssh.rb:106:in `tap'
/Users/kyledecot/.rvm/gems/ruby-2.0.0-p247@skateboxes/gems/sshkit-1.1.0/lib/sshkit/backends/netssh.rb:106:in `_execute'
/Users/kyledecot/.rvm/gems/ruby-2.0.0-p247@skateboxes/gems/sshkit-1.1.0/lib/sshkit/backends/netssh.rb:54:in `execute'
/Users/kyledecot/.rvm/gems/ruby-2.0.0-p247@skateboxes/bundler/gems/capistrano-puma-4068552029ae/lib/capistrano/tasks/puma.cap:32:in `block (3 levels) in <top (required)>'
/Users/kyledecot/.rvm/gems/ruby-2.0.0-p247@skateboxes/gems/sshkit-1.1.0/lib/sshkit/backends/netssh.rb:42:in `instance_exec'
/Users/kyledecot/.rvm/gems/ruby-2.0.0-p247@skateboxes/gems/sshkit-1.1.0/lib/sshkit/backends/netssh.rb:42:in `run'
/Users/kyledecot/.rvm/gems/ruby-2.0.0-p247@skateboxes/gems/sshkit-1.1.0/lib/sshkit/runners/parallel.rb:12:in `block (2 levels) in execute'
Tasks: TOP => puma:start

Puma.rb not found error.

I have my config file in config/puma.rb but the capistrano task always raises the error puma.rb not found error and generates a new file

I even tried to use

set :puma_conf,  -> { File.join(current_path, 'config/puma.rb') } 

which also raises some error and aborts the deployment.

Could someone point the mistake i am making?

puma_pid not set

I set up a very simple puma deploy, I only set repo_url and puma_role. When I tried to deploy, it failed trying to stop puma:

DEBUG[da937ddc] Running /usr/bin/env [ -f  ] on 10.0.0.2
DEBUG[da937ddc] Command: [ -f  ]
DEBUG[da937ddc] Finished in 0.003 seconds with exit status 0 (successful).
DEBUG[40ba6f3f] Running /usr/bin/env kill -0 $( cat  ) on 10.0.0.2
DEBUG[40ba6f3f] Command: kill -0 $( cat  )

It seems like the defaults task is not being run?

When Gemfile.lock changes, Puma does not do the right thing on restart, so Cap-puma needs a workaround

If I bundle update and then commit the new Gemfile.lock,
changes made thusly are not reflected on my running server
after executing a 'cap production deploy'.

However, if I stop and restart he puma server on production,
suddenly the Gemfile.lock changes are in fact reflected in the
server's behavior.

As far as I am concerned, this appears to be a bug in Puma's restart.

However since we have to work with the puma we have, I think that
capistrano-puma needs to work around this bug by stopping and starting
puma rather than pumactl restart during deployment.

Thoughts?

(I am assuming here that it would be very difficult to determine if the
Gemfile.lock has different content between the currently running puma
instance and the newly deployed source tree)

I'm happy to make a PR if it is desired.

staging env don't work

hey, i use capistrano and puma .but my staging env don't work.

deploy.rb

set :puma_env, fetch(:rack_env, fetch(:rails_env, 'staging'))

staging.rb

set :rails_env, "staging"
set :rack_env, "staging"
set :puma_env, "staging"

but when i deploy . they always Environment: production。

how can i fix that.

thank u

Monitoring with god?

This is more of a question, but I'm trying to figure out if pumactl actually takes care of cases where puma crashes. When I kill the process, it doesn't seem to restart.

Ideally, I'd like to monitor puma with the god gem so that it's automatically restarted if it dies, but not sure how I should setup my watch so god properly runs the start/restart tasks with pumactl.

Thanks!

Problems with deploying a Dashing project

I'm facing this problem when I deploy a dashing project: When run "Cap Env deploy", the dashboard is not able to communicate with the events.
But if I ssh the instance and manually runs the start rake it works:

PATH=/.rbenv/shims:/.rbenv/bin:$PATH RBENV_ROOT=/opt/rbenv RBENV_VERSION=2.1.1 RACK_ENV=staging RBENV_ROOT=/opt/rbenv RBENV_VERSION=2.1.1 /opt/rbenv/bin/rbenv exec bundle exec puma -C /var/www/application/shared/puma.rb

I have tried to modify the task and the rbenv setting but still the problem is there. I have made a post to document the problem because is happening also with Unicorn.
http://www.joseantoniopio.com/programming/deploying-dashing-with-unicorn-or-puma/

Can someone help me to find the issue?

ActiveRecord::Base.establish_connection on_worker_boot

The puma readme suggests the following code when preloading the app:

on_worker_boot do
  ActiveSupport.on_load(:active_record) do
    ActiveRecord::Base.establish_connection
  end
end

Should this be a part of the config capistrano-puma generates?

multiple puma_bind

I have two binds for puma:

bind 'tcp://0.0.0.0:9220'
bind 'unix:///tmp/unicorn.sock'

Would it possible to support them both via set :puma_bind? Perhaps supporting an array option.

i get this error:cannot load such file -- capistrano/puma

gemfile

group :development, :test do
  gem 'capistrano', '~> 3.1.0'
  gem 'capistrano-rails',   '~> 1.1', require: false
  gem 'capistrano-bundler', '~> 1.1', require: false
  gem 'capistrano-rbenv', '~> 2.0', require: false
  gem 'capistrano3-puma', github: "seuros/capistrano-puma"
end

capfile

# Load DSL and Setup Up Stages
require 'capistrano/setup'

# Includes default deployment tasks
require 'capistrano/deploy'
# Includes tasks from other gems included in your Gemfile
#
# For documentation on these, see for example:
#
#   https://github.com/capistrano/rvm
#   https://github.com/capistrano/rbenv
#   https://github.com/capistrano/chruby
#   https://github.com/capistrano/bundler
#   https://github.com/capistrano/rails
#
# require 'capistrano/rvm'
require 'capistrano/rbenv'
require 'capistrano/puma'
# require 'capistrano/chruby'
require 'capistrano/bundler'
require 'capistrano/rails/assets'
require 'capistrano/rails/migrations'

# Loads custom tasks from `lib/capistrano/tasks' if you have any defined.
Dir.glob('lib/capistrano/tasks/*.cap').each { |r| import r }

when i run cap production deploy
i get this error

@reim ➜  mywy rbenv:(2.1.0-rc1) git:(master) ✗ cap production deploy --trace
cap aborted!
cannot load such file -- capistrano/puma
/Users/stephen/.rbenv/versions/2.1.0-rc1/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require'
/Users/stephen/.rbenv/versions/2.1.0-rc1/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require'
/Users/stephen/mywy/Capfile:18:in `<top (required)>'
/Users/stephen/.rbenv/versions/2.1.0-rc1/lib/ruby/gems/2.1.0/gems/rake-10.1.1/lib/rake/rake_module.rb:25:in `load'
/Users/stephen/.rbenv/versions/2.1.0-rc1/lib/ruby/gems/2.1.0/gems/rake-10.1.1/lib/rake/rake_module.rb:25:in `load_rakefile'
/Users/stephen/.rbenv/versions/2.1.0-rc1/lib/ruby/gems/2.1.0/gems/rake-10.1.1/lib/rake/application.rb:637:in `raw_load_rakefile'
/Users/stephen/.rbenv/versions/2.1.0-rc1/lib/ruby/gems/2.1.0/gems/rake-10.1.1/lib/rake/application.rb:94:in `block in load_rakefile'
/Users/stephen/.rbenv/versions/2.1.0-rc1/lib/ruby/gems/2.1.0/gems/rake-10.1.1/lib/rake/application.rb:165:in `standard_exception_handling'
/Users/stephen/.rbenv/versions/2.1.0-rc1/lib/ruby/gems/2.1.0/gems/rake-10.1.1/lib/rake/application.rb:93:in `load_rakefile'
/Users/stephen/.rbenv/versions/2.1.0-rc1/lib/ruby/gems/2.1.0/gems/capistrano-3.1.0/lib/capistrano/application.rb:24:in `load_rakefile'
/Users/stephen/.rbenv/versions/2.1.0-rc1/lib/ruby/gems/2.1.0/gems/rake-10.1.1/lib/rake/application.rb:77:in `block in run'
/Users/stephen/.rbenv/versions/2.1.0-rc1/lib/ruby/gems/2.1.0/gems/rake-10.1.1/lib/rake/application.rb:165:in `standard_exception_handling'
/Users/stephen/.rbenv/versions/2.1.0-rc1/lib/ruby/gems/2.1.0/gems/rake-10.1.1/lib/rake/application.rb:75:in `run'
/Users/stephen/.rbenv/versions/2.1.0-rc1/lib/ruby/gems/2.1.0/gems/capistrano-3.1.0/lib/capistrano/application.rb:15:in `run'
/Users/stephen/.rbenv/versions/2.1.0-rc1/lib/ruby/gems/2.1.0/gems/capistrano-3.1.0/bin/cap:3:in `<top (required)>'
/Users/stephen/.rbenv/versions/2.1.0-rc1/bin/cap:23:in `load'
/Users/stephen/.rbenv/versions/2.1.0-rc1/bin/cap:23:in `<main>'

cap production puma:stop reports "Operation not permitted"

After starting via cap production puma:start when attempting to run cap production puma:stop I get:

 INFO [25f6dd38] Running cd /var/www/skateboxes/current && bundle exec pumactl -S /var/www/skateboxes/shared/tmp/pids/puma.state stop on 162.243.33.179
DEBUG [25f6dd38] Command: cd /var/www/skateboxes/current && bundle exec pumactl -S /var/www/skateboxes/shared/tmp/pids/puma.state stop
DEBUG [25f6dd38]    Operation not permitted
cap aborted!
cd /var/www/skateboxes/current && bundle exec pumactl -S /var/www/skateboxes/shared/tmp/pids/puma.state stop stdout: Nothing written
cd /var/www/skateboxes/current && bundle exec pumactl -S /var/www/skateboxes/shared/tmp/pids/puma.state stop stderr: Nothing written
/Users/kyledecot/.rvm/gems/ruby-2.0.0-p247@skateboxes/gems/sshkit-1.1.0/lib/sshkit/command.rb:94:in `exit_status='
/Users/kyledecot/.rvm/gems/ruby-2.0.0-p247@skateboxes/gems/sshkit-1.1.0/lib/sshkit/backends/netssh.rb:125:in `block (4 levels) in _execute'
/Users/kyledecot/.rvm/gems/ruby-2.0.0-p247@skateboxes/gems/net-ssh-2.7.0/lib/net/ssh/connection/channel.rb:551:in `call'
/Users/kyledecot/.rvm/gems/ruby-2.0.0-p247@skateboxes/gems/net-ssh-2.7.0/lib/net/ssh/connection/channel.rb:551:in `do_request'
/Users/kyledecot/.rvm/gems/ruby-2.0.0-p247@skateboxes/gems/net-ssh-2.7.0/lib/net/ssh/connection/session.rb:561:in `channel_request'
/Users/kyledecot/.rvm/gems/ruby-2.0.0-p247@skateboxes/gems/net-ssh-2.7.0/lib/net/ssh/connection/session.rb:465:in `dispatch_incoming_packets'
/Users/kyledecot/.rvm/gems/ruby-2.0.0-p247@skateboxes/gems/net-ssh-2.7.0/lib/net/ssh/connection/session.rb:221:in `preprocess'
/Users/kyledecot/.rvm/gems/ruby-2.0.0-p247@skateboxes/gems/net-ssh-2.7.0/lib/net/ssh/connection/session.rb:205:in `process'
/Users/kyledecot/.rvm/gems/ruby-2.0.0-p247@skateboxes/gems/net-ssh-2.7.0/lib/net/ssh/connection/session.rb:169:in `block in loop'
/Users/kyledecot/.rvm/gems/ruby-2.0.0-p247@skateboxes/gems/net-ssh-2.7.0/lib/net/ssh/connection/session.rb:169:in `loop'
/Users/kyledecot/.rvm/gems/ruby-2.0.0-p247@skateboxes/gems/net-ssh-2.7.0/lib/net/ssh/connection/session.rb:169:in `loop'
/Users/kyledecot/.rvm/gems/ruby-2.0.0-p247@skateboxes/gems/net-ssh-2.7.0/lib/net/ssh/connection/channel.rb:269:in `wait'
/Users/kyledecot/.rvm/gems/ruby-2.0.0-p247@skateboxes/gems/sshkit-1.1.0/lib/sshkit/backends/netssh.rb:147:in `block (2 levels) in _execute'
/Users/kyledecot/.rvm/gems/ruby-2.0.0-p247@skateboxes/gems/net-ssh-2.7.0/lib/net/ssh/connection/channel.rb:514:in `call'
/Users/kyledecot/.rvm/gems/ruby-2.0.0-p247@skateboxes/gems/net-ssh-2.7.0/lib/net/ssh/connection/channel.rb:514:in `do_open_confirmation'
/Users/kyledecot/.rvm/gems/ruby-2.0.0-p247@skateboxes/gems/net-ssh-2.7.0/lib/net/ssh/connection/session.rb:545:in `channel_open_confirmation'
/Users/kyledecot/.rvm/gems/ruby-2.0.0-p247@skateboxes/gems/net-ssh-2.7.0/lib/net/ssh/connection/session.rb:465:in `dispatch_incoming_packets'
/Users/kyledecot/.rvm/gems/ruby-2.0.0-p247@skateboxes/gems/net-ssh-2.7.0/lib/net/ssh/connection/session.rb:221:in `preprocess'
/Users/kyledecot/.rvm/gems/ruby-2.0.0-p247@skateboxes/gems/net-ssh-2.7.0/lib/net/ssh/connection/session.rb:205:in `process'
/Users/kyledecot/.rvm/gems/ruby-2.0.0-p247@skateboxes/gems/net-ssh-2.7.0/lib/net/ssh/connection/session.rb:169:in `block in loop'
/Users/kyledecot/.rvm/gems/ruby-2.0.0-p247@skateboxes/gems/net-ssh-2.7.0/lib/net/ssh/connection/session.rb:169:in `loop'
/Users/kyledecot/.rvm/gems/ruby-2.0.0-p247@skateboxes/gems/net-ssh-2.7.0/lib/net/ssh/connection/session.rb:169:in `loop'
/Users/kyledecot/.rvm/gems/ruby-2.0.0-p247@skateboxes/gems/sshkit-1.1.0/lib/sshkit/backends/netssh.rb:149:in `block in _execute'
/Users/kyledecot/.rvm/gems/ruby-2.0.0-p247@skateboxes/gems/sshkit-1.1.0/lib/sshkit/backends/netssh.rb:106:in `tap'
/Users/kyledecot/.rvm/gems/ruby-2.0.0-p247@skateboxes/gems/sshkit-1.1.0/lib/sshkit/backends/netssh.rb:106:in `_execute'
/Users/kyledecot/.rvm/gems/ruby-2.0.0-p247@skateboxes/gems/sshkit-1.1.0/lib/sshkit/backends/netssh.rb:54:in `execute'
/Users/kyledecot/.rvm/gems/ruby-2.0.0-p247@skateboxes/bundler/gems/capistrano-puma-e8981d4482dd/lib/capistrano/tasks/puma.cap:42:in `block (4 levels) in <top (required)>'
/Users/kyledecot/.rvm/gems/ruby-2.0.0-p247@skateboxes/gems/sshkit-1.1.0/lib/sshkit/backends/netssh.rb:42:in `instance_exec'
/Users/kyledecot/.rvm/gems/ruby-2.0.0-p247@skateboxes/gems/sshkit-1.1.0/lib/sshkit/backends/netssh.rb:42:in `run'
/Users/kyledecot/.rvm/gems/ruby-2.0.0-p247@skateboxes/gems/sshkit-1.1.0/lib/sshkit/runners/parallel.rb:12:in `block (2 levels) in execute'

No feedback on missing shared/log directory

Hello,

I'm using capistrano-puma for the first time and ran into some difficultlies on first run.

Firstly puma:start failed silently due to missing a missing log directory.

Prior to that, puma:start failed loudly when share/tmp/pids and shared/tmp/sockets could not be found.

Is it fair to fair that puma:check should notify the user about missing directories?

jungle setup: Syntax error: ";;" unexpected

cap puma:jungle:setup

on the add application task:

 INFO [fc580242] Running /usr/bin/env sudo /etc/init.d/puma add '/home/ubuntu/apps/myapp-rails/current' ubuntu on 162.243.255.22x
cap aborted!
SSHKit::Command::Failed: sudo stdout: Nothing written
sudo stderr: Nothing written
/Users/kain/.rvm/gems/ruby-2.1.1/gems/sshkit-1.3.0/lib/sshkit/command.rb:94:in `exit_status='
/Users/kain/.rvm/gems/ruby-2.1.1/gems/sshkit-1.3.0/lib/sshkit/backends/netssh.rb:142:in `block (4 levels) in _execute'

If I run the command manually on the server I get this error:

/etc/init.d/puma: 254: /etc/init.d/puma: Syntax error: ";;" unexpected (expecting "fi")

snippet of line 254 and context:

fi
case "$?" in
  0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
esac
;;

Add :stage to a puma's monit file. (Namespace collision)

What if to add "#{fetch(:application)}_#{fetch(:stage)}" to puma's monit file ?
like we do with nginx /etc/nginx/sites-enabled/appname_staging

Issue:
For now, task cap puma:monit:config generates /etc/monit/conf.d/puma_appname.conf file
content the file is

. . .
check process puma_appname
. . .

If we have 2 apps on the same server (staging and production) we get namespace collision.
Should we add a stage to separate them?

Unable to run cap production puma:jungle:install

When attempting to run cap production puma:jungle:install I get:

DEBUG Uploading /tmp/run-puma 0.0%
 INFO Uploading /tmp/run-puma 100.0%
 INFO [7c6dec29] Running chmod +x /tmp/run-puma on 162.243.33.179
DEBUG [7c6dec29] Command: chmod +x /tmp/run-puma
 INFO [7c6dec29] Finished in 0.264 seconds with exit status 0 (successful).
DEBUG Uploading /tmp/puma 0.0%
 INFO Uploading /tmp/puma 100.0%
 INFO [f32b7752] Running chmod +x /tmp/puma on 162.243.33.179
DEBUG [f32b7752] Command: chmod +x /tmp/puma
 INFO [f32b7752] Finished in 0.268 seconds with exit status 0 (successful).
 INFO [a0a78463] Running sudo mv /tmp/run-puma /usr/local/bin/run-puma on 162.243.33.179
DEBUG [a0a78463] Command: ( RAILS_ENV=production sudo mv /tmp/run-puma /usr/local/bin/run-puma )
DEBUG [a0a78463]    [sudo] password for deploy:

The problem is that my deploy user doesn't have a password. What would you suggest?

Please do not put files like `puma.pid` in `shared_path` by default but into `current_path`

The current defaults look like below.

    $ more lib/capistrano/tasks/puma.cap
    […]
    namespace :load do
      task :defaults do
        set :puma_default_hooks, -> { true }
        set :puma_role, :app
        set :puma_env, -> { fetch(:rack_env, fetch(:rails_env, fetch(:stage))) }
        # Configure "min" to be the minimum number of threads to use to answer
        # requests and "max" the maximum.
        set :puma_threads, [0, 16]
        set :puma_workers, 0
        set :puma_rackup, -> { File.join(current_path, 'config.ru') }
        set :puma_state, -> { File.join(shared_path, 'tmp', 'pids', 'puma.state') }
        set :puma_pid, -> { File.join(shared_path, 'tmp', 'pids', 'puma.pid') }
        set :puma_bind, -> { File.join("unix://#{shared_path}", 'tmp', 'sockets', 'puma.sock') }
        set :puma_conf, -> { File.join(shared_path, 'puma.rb') }
        set :puma_access_log, -> { File.join(shared_path, 'log', 'puma_access.log') }
        set :puma_error_log, -> { File.join(shared_path, 'log', 'puma_error.log') }
        set :puma_init_active_record, false
        set :puma_preload_app, true
        set :puma_prune_bundler, false
    […]

Doesn’t using shared_path for puma.state, puma.pid and puma.sock lead to problems when you use for example a staging and a production environment as they are not differently named?

Also Puma’s jungle scripts use current_path/tmp/.

PIDFILE=$1/tmp/puma/pid
STATEFILE=$1/tmp/puma/state

NoMethodError: undefined method `verbosity' for "/usr/bin/env puma:start\n":String

** Invoke puma:smart_restart (first_time)
** Execute puma:smart_restart
** Invoke puma:restart (first_time)
** Execute puma:restart
DEBUG [0f230bae] Running /usr/bin/env if test ! -d /home/deploy/apps/aakr_staging_ru/current; then echo "Directory does not exist '/home/deploy/apps/aakr_staging_ru/current'" 1>&2; false; fi on 104.131.0.0
DEBUG [0f230bae] Command: if test ! -d /home/deploy/apps/aakr_staging_ru/current; then echo "Directory does not exist '/home/deploy/apps/aakr_staging_ru/current'" 1>&2; false; fi
DEBUG [0f230bae] Finished in 3.251 seconds with exit status 0 (successful).
DEBUG [41e5db22] Running /usr/bin/env [ -f /home/deploy/apps/aakr_staging_ru/shared/tmp/pids/puma.pid ] on 104.131.0.0
DEBUG [41e5db22] Command: [ -f /home/deploy/apps/aakr_staging_ru/shared/tmp/pids/puma.pid ]
DEBUG [41e5db22] Finished in 0.500 seconds with exit status 1 (failed).
cap aborted!
NoMethodError: undefined method `verbosity' for "/usr/bin/env puma:start\n":String
/home/itsnikolay/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/sshkit-1.2.0/lib/sshkit/formatters/pretty.rb:10:in `write'
/home/itsnikolay/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/sshkit-1.2.0/lib/sshkit/backends/printer.rb:14:in `block in execute'
/home/itsnikolay/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/sshkit-1.2.0/lib/sshkit/backends/printer.rb:13:in `tap'
/home/itsnikolay/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/sshkit-1.2.0/lib/sshkit/backends/printer.rb:13:in `execute'
/home/itsnikolay/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/capistrano3-puma-0.8.2/lib/capistrano/tasks/puma.cap:103:in `block (6 levels) in <top (required)>'
/home/itsnikolay/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/sshkit-1.2.0/lib/sshkit/backends/abstract.rb:89:in `with'
/home/itsnikolay/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/capistrano3-puma-0.8.2/lib/capistrano/tasks/puma.cap:97:in `block (5 levels) in <top (required)>'
/home/itsnikolay/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/sshkit-1.2.0/lib/sshkit/backends/abstract.rb:81:in `within'
/home/itsnikolay/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/capistrano3-puma-0.8.2/lib/capistrano/tasks/puma.cap:96:in `block (4 levels) in <top (required)>'
/home/itsnikolay/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/sshkit-1.2.0/lib/sshkit/backends/netssh.rb:54:in `instance_exec'
/home/itsnikolay/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/sshkit-1.2.0/lib/sshkit/backends/netssh.rb:54:in `run'
/home/itsnikolay/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/sshkit-1.2.0/lib/sshkit/runners/parallel.rb:12:in `block (2 levels) in execute'
Tasks: TOP => puma:restart

I try to use jungle to start pamas

My deploy/config.rb file

set :puma_init_active_record, true

set :rbenv_type, :system
set :rbenv_ruby, '2.1.3'
set :rbenv_prefix, "RBENV_ROOT=#{fetch(:rbenv_path)} RBENV_VERSION=#{fetch(:rbenv_ruby)} #{fetch(:rbenv_path)}/bin/rbenv exec"
set :rbenv_map_bins, %w{rake gem bundle ruby rails}
set :linked_files, %w{config/database.yml}
set :linked_dirs, %w{bin log tmp/pids tmp/cache tmp/sockets vendor/bundle public/system public/uploads}

namespace :deploy do
  task :restart do
    invoke 'puma:jungle:restart'
  end
end

My Capfile

require 'capistrano/setup'
require 'capistrano/deploy'

require 'capistrano/rbenv'
require 'capistrano/bundler'
require 'capistrano/rails/assets'
require 'capistrano/rails/migrations'
require 'capistrano/puma'
require 'capistrano/puma/jungle'
require 'capistrano/puma/monit'
require 'capistrano/puma/nginx'

And one more question, how to set deploy task to run jungle ?
In readme there's nothing about it. =(

bash: bundle: command not found

when I run "cap production puma:status"

I got results like this

DEBUG [9f248c6e] Running if test ! -d /app/www/appbg.xiaoma.com/current; then echo "Directory does not exist '/app/www/appbg.xiaoma.com/current'" 1>&2; false; fi on bbs.xiaoma.com
DEBUG [9f248c6e] Command: if test ! -d /app/www/appbg.xiaoma.com/current; then echo "Directory does not exist '/app/www/appbg.xiaoma.com/current'" 1>&2; false; fi
DEBUG [9f248c6e] Finished in 0.898 seconds with exit status 0 (successful).
 INFO [a5caa2b2] Running bundle exec pumactl -S /app/www/appbg.xiaoma.com/shared/tmp/pids/puma.state status on bbs.xiaoma.com
DEBUG [a5caa2b2] Command: bundle exec pumactl -S /app/www/appbg.xiaoma.com/shared/tmp/pids/puma.state status
DEBUG [a5caa2b2]    bash: bundle: command not found

I found capistrano 3 bundler task run this way

DEBUG [09277beb] Command: cd /app/www/appbg.xiaoma.com/releases/20131120095329 && /usr/local/rvm/bin/rvm 1.9.3@ruby193rails3215 do bundle --gemfile /app/www/appbg.xiaoma.com/releases/20131120095329/Gemfile --path /app/www/appbg.xiaoma.com/shared/bundle --deployment --quiet --binstubs /app/www/appbg.xiaoma.com/shared/bin --without development test

how to solve this problem?

nginx_config fails quietly if puma_nginx role not set

For me, as a beginner user of capistrano, it wasn't obvious at all that I need to set up role puma_nginx in my config/deploy/<environment>.rb in order to upload nginx config. And the task output wasn't very helpful:

$ cap production puma:nginx_config
DEBUG[0ca628c2] Running /usr/bin/env [ ! -d /usr/local/rbenv/versions/2.1.3 ] on test10
DEBUG[0ca628c2] Command: [ ! -d /usr/local/rbenv/versions/2.1.3 ]
DEBUG[0ca628c2] Finished in 0.670 seconds with exit status 1 (failed).

Only after looking at the source code I understood that I need to set the role puma_nginx to make the task work. Maybe it's something every advanced Capistrano user knows right away, but for newbies like me I think it's worth metioning in the README. Or even the task should argue about the role not set, not just being quiet.

If it's okay, I'll do a PR. Or am I doing it wrong and nobody had such problems before me?

templates nginx_conf.erb assigned but unused variable - flags

upstream puma_<%= fetch(:nginx_config_name) %> { <%
  flags = 'fail_timeout=0'
  @backends = [fetch(:puma_bind)].flatten.map do |m|
  etype, address  = /(tcp|unix|ssl):\/\/(.+)/.match(m).captures
  if etype =='unix'
    "server #{etype}:#{address} #{fetch(:nginx_socket_flags)};"
  else
    "server #{address.gsub(/0\.0\.0\.0(.+)/, "127.0.0.1\\1")} #{fetch(:nginx_http_flags)};"
  end
end
%><% @backends.each do |server|  %>
  <%= server %><% end %>
}

config/deploy/templates/nginx_conf.erb|3 warning| assigned but unused variable - flags

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.