title: Puma: Status file not found
body: <p>I am trying to deploy a Rails application with Capistrano. I had an issue of <code>bundler: command not found: pumactl</code>, which I seem to have resolved by adding the puma gem to my Gemfile outside of the <code>:development</code> group.</p>
  
  <p><strong>Gemfile</strong></p>
  
  <pre><code>source 'https://rubygems.org'
  
  gem 'rails', '4.2.0'
  gem 'sass-rails', '~&gt; 5.0'
  gem 'semantic-ui-sass', github: 'doabit/semantic-ui-sass'
  gem 'uglifier', '&gt;= 1.3.0'
  gem 'coffee-rails', '~&gt; 4.1.0'
  gem 'mongoid'
  gem 'jquery-rails'
  gem 'turbolinks'
  gem 'jbuilder', '~&gt; 2.0'
  gem 'sdoc', '~&gt; 0.4.0', group: :doc
  gem 'prawn-rails', '0.1.1'
  gem 'fastimage', '1.6.6'
  gem 'mini_magick', '4.0.4'
  gem 'carrierwave', '0.10.0'
  gem 'puma', '2.11.1'
  
  group :development, :test do
    gem 'capistrano', '3.3.5'
    gem 'capistrano-rvm', '0.1.2'
    gem 'capistrano-rails', '1.1.2'
    gem 'capistrano-bundler', '1.1.4'
    gem 'capistrano3-puma', '0.8.5'
    gem 'web-console', '~&gt; 2.0'
    gem 'spring'
  end
  </code></pre>
  
  <p>Now when I attempt to <code>cap production deploy:initial --trace</code> (or <code>cap production deploy --trace</code>), I get the following output:</p>
  
  <pre><code>...
  INFO [7314ca0d] Running ~/.rvm/bin/rvm default do bundle exec pumactl -S /home/myuser/apps/myapp/shared/tmp/pids/puma.state restart as myuser@mydomain.com
  DEBUG [7314ca0d] Command: cd /home/myuser/apps/myapp/releases/20150213082155 &amp;&amp; ~/.rvm/bin/rvm default do bundle exec pumactl -S /home/myuser/apps/myapp/shared/tmp/pids/puma.state restart
  DEBUG [7314ca0d]    Status file not found: /home/myuser/apps/myapp/shared/tmp/pids/puma.state
  DEBUG [7314ca0d]    
  cap aborted!
  SSHKit::Runner::ExecuteError: Exception while executing as myuser@mydomain.com: Exception while executing as myuser@mydomain.com: Exception while executing as myuser@mydomain.com: bundle exit status: 1
  bundle stdout: Nothing written
  bundle stderr: Nothing written
  ...
  </code></pre>
  
  <p>I was attempting to follow <a href="https://coderwall.com/p/ttrhow/deploying-rails-app-using-nginx-puma-and-capistrano-3" rel="nofollow">this tutorial</a>.</p>
  
  <p><strong>Capfile</strong></p>
  
  <pre><code>require 'capistrano/setup'
  require 'capistrano/deploy'
  require 'capistrano/puma'
  require 'capistrano/rvm'
  require 'capistrano/rails'
  require 'capistrano/rails/assets'
  require 'capistrano/rails/migrations'
  require 'capistrano/bundler'
  Dir.glob('lib/capistrano/tasks/*.rake').each { |r| import r }
  </code></pre>
  
  <p><strong>config/deploy.rb</strong></p>
  
  <pre><code>lock '3.3.5'
  
  set :user, 'myuser'
  set :application, 'myapp'
  set :repo_url, 'git@github.com:myuser/myapp-rails.git'
  set :scm, :git
  set :branch, 'master'
  set :keep_releases, 2
  set :format, :pretty
  set :log_level, :debug
  
  set :pty,             true
  set :use_sudo,        false
  set :stage,           :production
  set :deploy_via,      :remote_cache
  set :deploy_to,       "/home/#{fetch(:user)}/apps/#{fetch(:application)}"
  set :puma_bind,       "unix://#{shared_path}/tmp/sockets/#{fetch(:application)}-puma.sock"
  set :puma_state,      "#{shared_path}/tmp/pids/puma.state"
  set :puma_pid,        "#{shared_path}/tmp/pids/puma.pid"
  set :puma_access_log, "#{release_path}/log/puma.error.log"
  set :puma_error_log,  "#{release_path}/log/puma.access.log"
  set :ssh_options,     { forward_agent: true, user: fetch(:user), keys: %w(~/.ssh/id_rsa.pub) }
  set :puma_preload_app, true
  set :puma_worker_timeout, nil
  set :puma_init_active_record, false
  
  ## Linked Files &amp; Directories (Default None):
  # set :linked_files, %w{config/database.yml}
  # set :linked_dirs,  %w{bin log tmp/pids tmp/cache tmp/sockets vendor/bundle public/system}
  
  namespace :puma do
    desc 'Create Directories for Puma Pids and Socket'
    task :make_dirs do
      on roles(:app) do
        execute "mkdir #{shared_path}/tmp/sockets -p"
        execute "mkdir #{shared_path}/tmp/pids -p"
      end
    end
  
    before :start, :make_dirs
  end
  
  namespace :deploy do
    desc "Make sure local git is in sync with remote."
    task :check_revision do
      on roles(:app) do
        unless `git rev-parse HEAD` == `git rev-parse origin/master`
          puts "WARNING: HEAD is not the same as origin/master"
          puts "Run `git push` to sync changes."
          exit
        end
      end
    end
  
    desc 'Initial Deploy'
    task :initial do
      on roles(:app) do
        before 'deploy:restart', 'puma:start'
        invoke 'deploy'
      end
    end
  
    desc 'Restart application'
    task :restart do
      on roles(:app), in: :sequence, wait: 5 do
        invoke 'puma:restart'
      end
    end
  
    before :starting,     :check_revision
    after  :finishing,    :compile_assets
    after  :finishing,    :cleanup
    after  :finishing,    :restart
  end
  
  # ps aux | grep puma    # Get puma pid
  # kill -s SIGUSR2 pid   # Restart puma
  # kill -s SIGTERM pid   # Stop puma
  </code></pre>
  
  <p>Any suggestions?</p>