0

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

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

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

更新:我只是尝试使用 bundle exec cap production deploy 进行部署并没有出错,但在运行 cap production deploy 时仍然出错

更新 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. 

部署.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

帽文件:

# 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 }
4

0 回答 0