【问题标题】:Using rackup command for thin server with a configuration file对带有配置文件的瘦服务器使用 rackup 命令
【发布时间】:2023-10-25 21:31:01
【问题描述】:

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

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) 传递给 Thin?

【问题讨论】:

  • 反之亦然:thin -C ... -R config/thin.yml
  • 当我尝试得到这个新错误 - 显示在问题中

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


【解决方案1】:

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

rackup: private_pub.ru,而应该是

rackup: current/private_pub.ru!

这是关于文件未找到的组合错误背后的原因......因为它在该目录中没有找到,因为它是错误的。

问题解决了。

【讨论】: