【问题标题】:Unable to start Unicorn server in capistrano 3无法在 capistrano 3 中启动 Unicorn 服务器
【发布时间】:2014-03-04 12:55:58
【问题描述】:

这是我的配置/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 分支中启动独角兽服务器

【问题讨论】:

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


    【解决方案1】:

    从以下行:

    没有这样的文件或目录 - /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,而不是 @987654328 @... :-P

    更新

    既然这样不行,我在capistrano3/unicorncode挖了一下,发现它要找的环境变量是:rails_env,所以也加上

    set :rails_env, :development
    

    【讨论】:

    • 是的,它已经在 config/deploy/development.rb 中了。但没有用。
    • 我正在从本地机器启动服务器。它只是说 unicorn 正在运行,当我在远程机器上使用 ps -ef|grep unicorn 检查时。它说它在部署-D而不是开发-D中运行。我没有看到 GUI 有任何变化。请让我知道该怎么做。
    • 显然这是设计使然(github.com/tablexi/capistrano3-unicorn/blob/master/lib/…) - 当你在开发中运行时,它通过-E deployment (我不知道为什么,但他们竭尽全力实现它,所以它没有错……)
    • 我在 config/unicorn/development.rb 中添加了 set :rails_env, :development
    • 是的,当你这样做时,它将运行exec unicorn -c development -E deployment -D ...。 -c 告诉它配置文件名是什么...
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2013-11-22
    • 2013-06-19
    • 1970-01-01
    • 1970-01-01
    • 2014-12-23
    • 2017-03-05
    • 2016-07-19
    相关资源
    最近更新 更多