I use Capistrano to deploy my Rails app.
However, when I deploy my application, puma.pid
file is not being created, which leads to a problem - I can't restart server or deploy new version with capistrano - capistrano fails to stop puma
, because puma.pid
don't exests and it assumes no puma processes is running. And I get ADDRESS ALREADY IN USE
error when capistrano tries to run another version of puma.
Here is my deploy.rb
lock '3.4.0'
set :application, 'appname'
set :repo_url, 'giturl'
set :deploy_to, '/home/user/appname'
set :pty, false
set :linked_files, %w(config/application.yml config/database.yml)
set :linked_dirs, %w(log tmp/pids tmp/cache tmp/sockets vendor/bundle public/system public/uploads)
set :keep_releases, 5
set :rvm_type, :user
set :rvm_ruby_version, '2.3.0'
set :puma_rackup, -> { File.join(current_path, 'config.ru') }
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" # accept array for multi-bind
set :puma_conf, "#{shared_path}/config/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, 1
set :puma_workers, 1
set :puma_worker_timeout, nil
set :puma_init_active_record, true
set :puma_preload_app, true
set :sidekiq_config, 'config/sidekiq.yml'
set :sidekiq_log, '/dev/null'
set :sidekiq_processes, 1
set :clockwork_file, "clock.rb"
namespace :deploy do
desc 'Recompile all enterprise themes'
task :recompile_themes, [:command] => 'deploy:set_rails_env' do |task, args|
on primary(:app) do
within current_path do
with :rails_env => fetch(:rails_env) do
rake 'themes:recompile'
end
end
end
end
after :finishing, "deploy:recompile_themes"
end
require 'appsignal/capistrano'
And when I try to stop running Puma, for example, I get the following error:
...
DEBUG [37113fcf] Running [ -f /home/user/appname/shared/tmp/pids/puma.pid ] as user@server
DEBUG [37113fcf] Command: [ -f /home/user/appname/shared/tmp/pids/puma.pid ]
DEBUG [37113fcf] Finished in 0.273 seconds with exit status 1 (failed).
WARN Puma not running
And indeed, /home/user/appname/shared/tmp/pids/puma.pid
file don't exists. Do I need to create it manually or something? sidekiq.pid that is also being created the same way can be found in the same directory, so I don't think it's a permissions issue.
Any advices on how to approach this?