机架似乎认为我的环境是''生产时

时间:2014-07-07 18:57:39

标签: capistrano3 puma

机架应用程序错误:#mama日志中的# 在运行capistrano生产部署时。

的Gemfile:

source 'https://rubygems.org'

gem 'rails', '4.1.0'
gem 'mysql'
gem 'sass-rails', '~> 4.0.3'
gem 'uglifier', '>= 1.3.0'
gem 'coffee-rails', '~> 4.0.0'
gem 'jquery-rails'
gem 'turbolinks'
gem 'jbuilder', '~> 2.0'
gem 'sdoc', '~> 0.4.0',          group: :doc

gem 'spring',        group: :development
gem 'puma'

group :development do
  gem 'capistrano'
  gem 'capistrano-rails'
  gem 'capistrano3-puma'
  gem 'rvm1-capistrano3',require: false
end
gem 'capistrano3-nginx'

deploy.rb:

lock '3.2.1'

set :application, 'foobar'
set :repo_url, '/home/joeradtke/rails/foobar/.git'
set :app_port, '8500'
set :nginx_domains, "radtke.in www.radtke.in"
set :nginx_template, "config/nginx.conf.erb"

set :app_server_socket, "#{shared_path}/sockets/puma-#{fetch :application}.sock"

set :deploy_to, '/home/joe/foobar'
set :deploy_user, 'joe'
set :sudo_user, 'joe'

set :stage, :production

set :puma_init_active_record, true
set :puma_env, :production
set :puma_state, "#{shared_path}/tmp/pids/puma.state"

set :linked_files, %w{config/database.yml}
set :rvm1_ruby_version, "2.1.2"

set :linked_dirs, %w{bin log tmp/pids tmp/cache tmp/sockets vendor/bundle public/system}

set :ssh_options, {
  config:false
}
namespace :deploy do
  after :deploy, "nginx:restart"
  after :deploy, "puma:restart" 
end

部署/ production.rb:

server 'radtke.in', user: 'joe', roles: %w{web app}, primary: true

  set :ssh_options, {
    keys: %w(/home/joe/.ssh/id_rsa),
    forward_agent: true,
    auth_methods: %w(publickey)
  }

Capfile:

require 'capistrano/setup'

require 'capistrano/deploy'

require 'rvm1/capistrano3'

require 'capistrano/rails'
require 'capistrano/puma'
require 'capistrano/puma/jungle'
require 'capistrano/puma/monit'

require 'capistrano/nginx'

Dir.glob('lib/capistrano/tasks/*.rake').each { |r| import r }
封面生产部署运行良好但是 根网页显示:

“发生了一个非常低级的管道错误。请联系您当地的Maytag(tm)维修人员。”

可以服务器资产,所以nginx没问题。

我想我到处都是制作。

甚至尝试过添加 '': secret_key_base:..................到secret.yml文件。

我这两天都在愚弄这个。通常可以找到在线答案但不是为此。请帮忙。

Joe Radtke

1 个答案:

答案 0 :(得分:1)

我在将旧的Rails 1.9.3 Suspenders环境中的应用程序迁移到AWS上的新Rails 2.0环境时遇到了同样的问题。

首先显示错误消息“发生真正的低级管道错误。请联系您当地的Maytag(tm)维修人员。”是一种聪明的方式,说Puma有一个错误,你应该看看puma.log看看错误是什么......

tail -f /var/log/puma/puma.log

就我而言,我找到了这一行:

Rack app error: #<RuntimeError: Missing `secret_key_base` for 'production' environment, set this value in `config/secrets.yml`>
遗憾的是,我不够书呆子告诉你为什么这是一个问题,但我可以告诉你,我的config / secrets.yml不是问题。由于某种原因,文件没有在生产中正确加载,所以我做了两件事。首先,我确保美洲狮宝石在生产中加载:

group :production do
  gem 'puma'
end

我仍然遇到问题,所以我查看了application.rb文件并更改了

# Pick the frameworks you want:
require "active_record/railtie"
require "action_controller/railtie"
require "action_mailer/railtie"
require "sprockets/railtie"
# require "rails/test_unit/railtie"
require "http_logger"

# Require the gems listed in Gemfile, including any gems
# you've limited to :test, :development, or :production.
Bundler.require(:default, Rails.env)

require 'rails/all'

# Require the gems listed in Gemfile, including any gems
# you've limited to :test, :development, or :production.
Bundler.require(*Rails.groups)

我们在新的rails环境中使用的是什么。