使用具有配置文件的瘦服务器的rackup命令

时间:2015-08-21 16:47:38

标签: ruby-on-rails rack thin private-pub rackup

我正在尝试运行以下命令在生产环境中运行服务器:

rackup private_pub.ru -s thin -E production

private_pub.ru看起来像这样:

# Run with: rackup private_pub.ru -s thin -E production
require "bundler/setup"
require "yaml"
require "faye"
require "private_pub"

Faye::WebSocket.load_adapter('thin')

PrivatePub.load_config(File.expand_path("../config/private_pub.yml", __FILE__), ENV["RAILS_ENV"] || "production")
run PrivatePub.faye_app

我想将配置文件(thin.yml)传递给thin,如下所示:

#thin configuration for clazzoo_chat production deployment

user: deploy
group: deploy

所以这是我试图执行的命令:

bundle exec rackup $APP_ROOT/private_pub.ru -s thin -C $APP_ROOT/config/thin.yml start -E production

然而,Rackup不支持-C,因为这个参数适用于瘦...根据这些文档:https://github.com/macournoyer/thin/#configuration-files

我也尝试改变我的命令:

bundle exec thin -C config/thin.yml -R private_pub.ru start

然后我收到错误:

Exiting!
/home/deploy/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/thin-1.6.3/lib/rack/adapter/loader.rb:32:in `read': No such file or directory @ rb_sysopen - private_pub.ru (Errno::ENOENT)
    from /home/deploy/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/thin-1.6.3/lib/rack/adapter/loader.rb:32:in `load'
    from /home/deploy/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/thin-1.6.3/lib/thin/controllers/controller.rb:182:in `load_rackup_config'
    from /home/deploy/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/thin-1.6.3/lib/thin/controllers/controller.rb:72:in `start'
    from /home/deploy/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/thin-1.6.3/lib/thin/runner.rb:200:in `run_command'
    from /home/deploy/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/thin-1.6.3/lib/thin/runner.rb:156:in `run!'
    from /home/deploy/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/thin-1.6.3/bin/thin:6:in `<top (required)>'
    from /home/deploy/.rbenv/versions/2.2.2/bin/thin:23:in `load'
    from /home/deploy/.rbenv/versions/2.2.2/bin/thin:23:in `<main>'
Writing PID to current/tmp/pids/thin.0.pid

在我的设置中 - 当rackup运行时,如何将此配置(thin.yml)传递给精简版?

1 个答案:

答案 0 :(得分:1)

最终我意识到这是因为我的thin.yml中有一行是:

rackup: private_pub.ru,而它应该是

rackup: current/private_pub.ru!

这就是关于找不到文件的编组错误背后的原因...因为它在该目录中找不到,因为它错了。

问题解决了。