Rozmieszczam po raz pierwszy kropelkę Digital Ocean Ubuntu. Skonfigurowałem wszystko i wykonałem wszystkie kroki, a teraz jestem na etapie, w którym wydaję polecenie: cap production deploy:initial
. Tego polecenia wracam ten komunikat o błędzie:Capistrano: Nie wiem, jak zbudować zadanie "deploy: new_release_path"
cap aborted!
Don't know how to build task 'deploy:new_release_path' (see --tasks)
/Users/Christopher/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/rake-12.0.0/lib/rake/task_manager.rb:58:in `[]'
/Users/Christopher/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/rake-12.0.0/lib/rake/task.rb:361:in `[]'
/Users/Christopher/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/capistrano-3.7.1/lib/capistrano/dsl/task_enhancements.rb:12:in `after'
/Users/Christopher/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/capistrano-3.7.1/lib/capistrano/scm/git.rb:21:in `register_hooks'
/Users/Christopher/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/capistrano-3.7.1/lib/capistrano/configuration/plugin_installer.rb:28:in `install'
/Users/Christopher/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/capistrano-3.7.1/lib/capistrano/configuration.rb:155:in `install_plugin'
/Users/Christopher/ClientProjects/PawBookings/Capfile:3:in `<top (required)>'
/Users/Christopher/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/rake-12.0.0/lib/rake/rake_module.rb:28:in `load'
/Users/Christopher/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/rake-12.0.0/lib/rake/rake_module.rb:28:in `load_rakefile'
/Users/Christopher/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/rake-12.0.0/lib/rake/application.rb:687:in `raw_load_rakefile'
/Users/Christopher/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/rake-12.0.0/lib/rake/application.rb:96:in `block in load_rakefile'
/Users/Christopher/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/rake-12.0.0/lib/rake/application.rb:178:in `standard_exception_handling'
/Users/Christopher/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/rake-12.0.0/lib/rake/application.rb:95:in `load_rakefile'
/Users/Christopher/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/rake-12.0.0/lib/rake/application.rb:79:in `block in run'
/Users/Christopher/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/rake-12.0.0/lib/rake/application.rb:178:in `standard_exception_handling'
/Users/Christopher/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/rake-12.0.0/lib/rake/application.rb:77:in `run'
/Users/Christopher/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/capistrano-3.7.1/lib/capistrano/application.rb:14:in `run'
/Users/Christopher/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/capistrano-3.7.1/bin/cap:3:in `<top (required)>'
/Users/Christopher/.rbenv/versions/2.3.1/bin/cap:22:in `load'
/Users/Christopher/.rbenv/versions/2.3.1/bin/cap:22:in `<main>'
Capfile
# Load DSL and Setup Up Stages
require 'capistrano/scm/git'
install_plugin Capistrano::SCM::Git
require 'capistrano/setup'
require 'capistrano/deploy'
require 'capistrano/rails'
require 'capistrano/bundler'
require 'capistrano/rvm'
require 'capistrano/puma'
# Loads custom tasks from `lib/capistrano/tasks' if you have any defined.
Dir.glob('lib/capistrano/tasks/*.rake').each { |r| import r }
config/deploy.rb
# Change these
server '12.34.56.789', port: 80, roles: [:web, :app, :db], primary: true
set :repo_url, 'my_ssh_github_url'
set :application, 'app_name'
set :user, 'deploy_username'
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.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, 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}
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
config/nginx.conf
upstream puma {
server unix:///home/deploy_username/apps/app_name/shared/tmp/sockets/app_name-puma.sock;
}
server {
listen 80 default_server deferred;
# server_name example.com;
root /home/deploy_username/apps/app_name/current/public;
access_log /home/deploy_username/apps/app_name/current/log/nginx.access.log;
error_log /home/deploy_username/apps/app_name/current/log/nginx.error.log info;
location ^~ /assets/ {
gzip_static on;
expires max;
add_header Cache-Control public;
}
try_files $uri/index.html $uri @puma;
location @puma {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_redirect off;
proxy_pass http://puma;
}
error_page 500 502 503 504 /500.html;
client_max_body_size 10M;
keepalive_timeout 10;
}
Aktualizacja:
przeprowadziłem kilka linijek kodu w Capfile. Proces wydaje się zaczęły, ale teraz wydaje następujący komunikat o błędzie:
** Invoke production (first_time)
** Execute production
** Invoke load:defaults (first_time)
** Execute load:defaults
** Invoke bundler:map_bins (first_time)
** Execute bundler:map_bins
** Invoke deploy:set_rails_env (first_time)
** Execute deploy:set_rails_env
** Invoke deploy:set_linked_dirs (first_time)
** Execute deploy:set_linked_dirs
** Invoke deploy:set_rails_env
** Invoke rvm:hook (first_time)
** Execute rvm:hook
cap aborted!
Net::SSH::Disconnect: connection closed by remote host
Nowy 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'
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 }
to jest prawidłowa odpowiedź. –
Dzięki! To działało również dla mnie! – Tonmoy
Zobacz także https://github.com/capistrano/capistrano/issues/1824 – robd