Using rackup command for thin server with a configuration file

1.4k Views Asked by At

I am trying to run the following command to run a server on a production environment:

rackup private_pub.ru -s thin -E production

The private_pub.ru looks like this:

# 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

I want to pass a configuration file (thin.yml) to thin which looks as follows:

#thin configuration for clazzoo_chat production deployment

user: deploy
group: deploy

So this is the command I am trying to execute:

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

However rackup doesn't suppot -C as this argument is intended for thin...as per these docs :https://github.com/macournoyer/thin/#configuration-files

I have also tried altering my command to be:

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

but then I get error:

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

In my setup - how can I pass this configuration (thin.yml) to thin when rackup runs thin?

1

There are 1 best solutions below

0
On

Eventually I realised it was because I had a line in my thin.yml which was:

rackup: private_pub.ru, whereas it should have been

rackup: current/private_pub.ru!

This was the reason behind the consist error about the file not being found...because it was not found in that directory as it was wrong.

Problem solved.