seuros / capistrano-puma

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

Don't know how to build task 'start' #322

Closed davideghz closed 3 years ago

davideghz commented 3 years ago

Hello, I get that error while deploying.

$ cap production deploy
(Backtrace restricted to imported tasks)
cap aborted!
Don't know how to build task 'start' (See the list of available tasks with `cap --tasks`)

Tasks: TOP => production
(See full trace by running task with --trace)

I'm running Rails 6.1.3.1 on Ruby 2.6.6

Here below my config:

deploy/production.rb ``` # Change these # By default your port will be 22 server '34.255.41.74', port: 22, roles: [:web, :app, :db], primary: true set :repo_url, 'git@bitbucket.org:dreemteem/oti-manual.git' set :application, 'oti_production' set :user, 'ubuntu' set :puma_threads, [4, 16] set :puma_workers, 0 # Don't change these unless you know what you're doing 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.access.log" set :puma_error_log, "#{release_path}/log/puma.error.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, true # Change to false when not using ActiveRecord ## Defaults: # set :scm, :git # set :branch, :master # set :format, :pretty # set :log_level, :debug # set :keep_releases, 5 ## Linked Files & 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} set :linked_files, %w{config/master.key} 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" execute "mkdir #{shared_path}/log -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 invoke 'deploy' 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 ```
Capfile ``` # Load DSL and Setup Up Stages require 'capistrano/setup' require 'capistrano/deploy' require 'capistrano/rails' require 'capistrano/bundler' require 'capistrano/rvm' require 'capistrano/puma' 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 # install_plugin Capistrano::Puma::Monit # if you need the monit tasks # install_plugin Capistrano::Puma::Nginx # if you want to upload a nginx site template require "capistrano/scm/git" install_plugin Capistrano::SCM::Git # Loads custom tasks from `lib/capistrano/tasks' if you have any defined. Dir.glob('lib/capistrano/tasks/*.rake').each { |r| import r } ```
puma.rb ``` max_threads_count = ENV.fetch("RAILS_MAX_THREADS") { 5 } min_threads_count = ENV.fetch("RAILS_MIN_THREADS") { max_threads_count } threads min_threads_count, max_threads_count worker_timeout 3600 if ENV.fetch("RAILS_ENV", "development") == "development" port ENV.fetch("PORT") { 3000 } environment ENV.fetch("RAILS_ENV") { "development" } pidfile ENV.fetch("PIDFILE") { "tmp/pids/server.pid" } plugin :tmp_restart ```

Please let me know if you need more info, thanks a lot!

davideghz commented 3 years ago

Solved as follow

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
end

before 'deploy:starting', 'puma:make_dirs'