Capistrano:有些任务被解雇但没有输出而且什么也没做

时间:2016-10-18 20:16:04

标签: ruby-on-rails deployment migration capistrano

我尝试使用Capistrano(3.6)来部署我的应用程序,但有些任务不起作用,只返回任何内容。

当我执行cap production deploy时,从我的git服务器正确下载了版本,捆绑安装正常工作,并且文件已链接。但有些任务似乎被忽略了,例如" deploy:migrate"。

我尝试通过创建这两项任务来调试,以了解部署过程中发生的事情:

namespace :deploy do
  before :migrate, :debug do
    puts "BEFORE"
  end

  after :migrate, :debug do
    puts "AFTER"
  end
end

我看到我的任务在捆绑安装后正确挂钩:

00:03 bundler:install
      01 ~/.rvm/bin/rvm 2.3.0 do bundle install --path /home/myuser/app/shared/bundle --without development test --deployment --qui…
    ✔ 01 myuser@myhost 2.380s
BEFORE
AFTER
00:05 deploy:symlink:release

但正如您所看到的,BEFORE和AFTER之间没有任何反应,但我还有待迁移。

如果我单独运行任务cap production deploy:migrate,则没有输出且没有任何反应。

当我直接在远程主机RAILS_ENV=production bundle exec rails db:migrate上运行命令时,它没问题!

这与其他一些任务相同,例如puma:x,deploy:compile_asset等......

我的环境

我使用RVM(单用户)和ruby 2.3.0(双方) 我的应用程序是Rails 5(仅限api)

在我的Gemfile中

gem 'capistrano', '~> 3.6.0'
gem 'capistrano-rails', '~> 1.1'
gem 'capistrano-rvm', '~> 0.1.1'
gem 'capistrano3-puma', github: "seuros/capistrano-puma"

在我的Capfile中

require 'capistrano/rvm'
require 'capistrano/rails'
require 'capistrano/bundler'
require 'capistrano/puma'
require 'capistrano/puma/nginx'

我的deploy.rb

set :rvm_ruby_version, '2.3.0'

set :application, 'myapp'
set :repo_url, 'git@gitlab.mydomain.com:me/myapp.git'
set :deploy_to, '/home/myuser/app'

append :linked_files, 'config/database.yml', 'config/secrets.yml'
append :linked_dirs, 'log', 'tmp/pids', 'tmp/cache', 'tmp/sockets'

set :nginx_config_name, 'myapp'
set :nginx_server_name, 'myapp.mydomain.com'

我的生产.rb

server 'myhost', user: 'myuser', roles: %(app web db)

set :rails_env, 'production'

感谢您的帮助!

1 个答案:

答案 0 :(得分:4)

你在production.rb中犯了错字。如果您运行cap production doctor,它会提醒您注意问题。

基本上,当您的意思是%(app web db)时,您已写过%w(app web db)

另见答案:Rails assets aren't compiling after Capistrano deployment