capistrano aborts - SSHKit :: Runner :: ExecuteError和Devise.secret_key未设置

时间:2017-08-15 21:09:02

标签: ruby ruby-on-rails-4 capistrano sshkit

我试图通过使用capistrano部署从开发到生产的更改来更新应用程序(Rails 4.1.12; ruby​​ 1.9.3p484)。下面是日志(我屏蔽了IP地址和建议的密钥)。

以前从未遇到过运行部署的问题。搜索并找到了类似错误的帖子,但没有找到解决方案。我按照说明将Devise.secret_key添加到Devise初始化程序并重新启动应用程序(dev和prod)。下一次尝试部署收到的相同错误,并建议使用不同的密钥。

非常感谢所有帮助,提示和建议。感谢。

更新:我刚尝试使用部署     捆绑exec cap生产部署 并没有得到错误,但在运行时仍然会出错     上限生产部署

更新2:我使用Figaro生成application.yml文件(并附加到gitignore)。在devise.rb文件中,我创建了一行config.secret_key = ENV["config.secret_key"]在application.yml文件中我创建了一行config.secret_key: 'random_128_chr_string'然后我重新启动了开发服务器并运行cap production deploy不幸的是出现了同样的错误。

cap production deploy
.
.
.
[deploy:migrate] Run `rake db:migrate`
[e0c2c251] Running bundle exec rake db:migrate as deployer@123.123.123.12
(Backtrace restricted to imported tasks)
cap aborted!
SSHKit::Runner::ExecuteError: Exception while executing as deployer@123.123.123.12: rake exit status: 1
rake stdout: Nothing written
rake stderr: rake aborted!
Devise.secret_key was not set. Please add the following to your Devise initializer:
config.secret_key = 'looong_string_of_numbers_and_letters'
Please ensure you restarted your application after installing Devise or setting the key. 

deploy.rb:

lock '>=3.2.1'

set :application, 'pepperslice'
set :repo_url, 'git@github.com:jeffaltman/pepperslice.git'
set :linked_dirs, %w{log tmp public/images/uploaded}
set :linked_files, %w{config/database.yml config/initializers/devise.rb config/initializers/smtp_settings.rb}

set :format, :pretty
set :log_level, :info

namespace :deploy do

  desc 'Restart application'
  task :restart do
    on roles(:app), in: :sequence, wait: 5 do
      execute "sudo /usr/sbin/service unicorn restart"
    end
  end

  after :publishing, :restart

  after :restart, :clear_cache do
    on roles(:web), in: :groups, limit: 3, wait: 10 do
      # Here we can do anything such as:
      # within release_path do
      #   execute :rake, 'cache:clear'
      # end
    end
  end
end

capfile:

# Load DSL and Setup Up Stages
require 'capistrano/setup'

# Includes default deployment tasks
require 'capistrano/deploy'

# Includes tasks from other gems included in your Gemfile
#
# For documentation on these, see for example:
#
#   https://github.com/capistrano/rvm
#   https://github.com/capistrano/rbenv
#   https://github.com/capistrano/chruby
#   https://github.com/capistrano/bundler
#   https://github.com/capistrano/rails
#
# require 'capistrano/rvm'
# require 'capistrano/rbenv'
# require 'capistrano/chruby'
require 'capistrano/bundler'
# require 'capistrano/rails/assets'
require 'capistrano/rails/migrations'
#require 'capistrano/ssh_doctor'
# Loads custom tasks from `lib/capistrano/tasks' if you have any defined.
Dir.glob('lib/capistrano/tasks/*.rake').each { |r| import r }

0 个答案:

没有答案