无法在capistrano 3中启动Unicorn服务器

时间:2014-03-04 12:55:58

标签: ruby-on-rails-4 amazon-ec2 unicorn capistrano3

这是我的config / unicorn / development.rb

app_path = "/home/ec2-user/apps/app_dev/current"

worker_processes 1
preload_app false
timeout 300
listen 3333

working_directory app_path
pid "#{app_path}/tmp/pids/unicorn.pid"

rails_env = 'development'

stderr_path "log/unicorn.log"
stdout_path "log/unicorn.log"

这是我的Capfile

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

# Includes default deployment tasks
require 'capistrano/deploy'


require 'capistrano/rvm'
# require 'capistrano/rbenv'
# require 'capistrano/chruby'
require 'capistrano/bundler'
# require 'capistrano/rails/assets'
require 'capistrano/rails/migrations'
require 'capistrano3/unicorn'
# require 'sidekiq/capistrano'

# Loads custom tasks from `lib/capistrano/tasks' if you have any defined.
Dir.glob('lib/capistrano/tasks/*.cap').each { |r| import r }

从我的本地环境运行以下命令"cap development unicorn:start"

我收到以下错误

RVM is not a function, selecting rubies with 'rvm use ...' will not work.
DEBUG [eba94152]    
DEBUG [eba94152]    You need to change your terminal emulator preferences to allow login shell.
DEBUG [eba94152]    Sometimes it is required to use `/bin/bash --login` as the command.
DEBUG [eba94152]    Please visit https://rvm.io/integration/gnome-terminal/ for a example.
DEBUG [eba94152]    
DEBUG [eba94152]    /home/ec2-user/apps/app_dev/shared/bundle/ruby/2.0.0/gems/unicorn-4.8.2/lib/unicorn/configurator.rb:75:in `read'
DEBUG [eba94152]    : 
DEBUG [eba94152]    No such file or directory - /home/ec2-user/apps/app_dev/current/config/unicorn/.rb
DEBUG [eba94152]     (
DEBUG [eba94152]    Errno::ENOENT
DEBUG [eba94152]    )
cap aborted!
bundle stdout: Nothing written
bundle stderr: Nothing written

让我知道如何在master分支中启动unicorn服务器

1 个答案:

答案 0 :(得分:6)

从以下一行:

  

没有这样的文件或目录 - /home/ec2-user/apps/app_dev/current/config/unicorn/.rb

我认为独角兽正在寻找/home/ec2-user/apps/app_dev/current/config/unicorn/<something should be here>.rb。这个“应该在这里的东西”,我希望是'开发',我想它正试图从fetch(:stage)

尝试添加到development.rb

set :stage, :development

修改

我没有注意到我建议的逻辑的循环(向未找到的文件添加内容以显示它的位置......) - 您应该将此行添加到config/deploy/development.rb,而不是config/unicorn/development.rb ... :-P

<强>更新

由于这不起作用,我在capistrano3/unicorn code挖了一下,发现它正在寻找的环境变量是:rails_env,所以也添加

set :rails_env, :development