Search code examples
ruby-on-railslinuxubuntuunicornupstart

Why come my upstart Unicorn rails server errors "rackup file (config.ru) not readable"


I've got a Rails app deploying to an Ubuntu 14.04 Amazon EC2 instance via Capistrano, then firing up a Unicorn server via a standard "upstart" service.

# Upstart Configuration

description     "Outright Mental Shop Webservice"
author          "Outright Mental Inc."

start on (net-device-up
          and local-filesystems
          and runlevel [2345])

stop on runlevel [016]

respawn

script
    cd /home/sh0/app/current/api
    exec su -s /bin/sh -c 'exec "$0" "$@"' sh0 -- unicorn -c config/unicorn.rb
end script

As a test, I ssh into that machine as user sh0 and run the exact commands in the script block of my upstart configuration file above. And my tail -f /home/sh0/app/shared/log/unicorn.stderr.log looks good:

I, [2015-05-16T00:15:36.966576 #2803]  INFO -- : Refreshing Gem list
I, [2015-05-16T00:15:38.320758 #2803]  INFO -- : unlinking existing socket=/home/sh0/app/shared/.unicorn.sock
I, [2015-05-16T00:15:38.321051 #2803]  INFO -- : listening on addr=/home/sh0/app/shared/.unicorn.sock fd=10
I, [2015-05-16T00:15:38.321385 #2803]  INFO -- : listening on addr=0.0.0.0:8080 fd=11
I, [2015-05-16T00:15:38.367685 #2808]  INFO -- : worker=1 ready
I, [2015-05-16T00:15:38.369270 #2803]  INFO -- : master process ready
I, [2015-05-16T00:15:38.372035 #2811]  INFO -- : worker=2 ready
I, [2015-05-16T00:15:38.372576 #2806]  INFO -- : worker=0 ready
I, [2015-05-16T00:15:38.375378 #2814]  INFO -- : worker=3 ready

But when I try to sudo service sh0 start my sudo tail -f /var/log/upstart/sh0.log looks bad:

/usr/local/lib/ruby/gems/2.0.0/gems/unicorn-4.9.0/lib/unicorn/configurator.rb:657:in `parse_rackup_file': rackup file (config.ru) not readable (ArgumentError)
        from /usr/local/lib/ruby/gems/2.0.0/gems/unicorn-4.9.0/lib/unicorn/configurator.rb:77:in `reload'
        from /usr/local/lib/ruby/gems/2.0.0/gems/unicorn-4.9.0/lib/unicorn/configurator.rb:68:in `initialize'
        from /usr/local/lib/ruby/gems/2.0.0/gems/unicorn-4.9.0/lib/unicorn/http_server.rb:100:in `new'
        from /usr/local/lib/ruby/gems/2.0.0/gems/unicorn-4.9.0/lib/unicorn/http_server.rb:100:in `initialize'
        from /usr/local/lib/ruby/gems/2.0.0/gems/unicorn-4.9.0/bin/unicorn:126:in `new'
        from /usr/local/lib/ruby/gems/2.0.0/gems/unicorn-4.9.0/bin/unicorn:126:in `<top (required)>'
        from /home/sh0/app/current/api/bin/unicorn:16:in `load'
        from /home/sh0/app/current/api/bin/unicorn:16:in `<main>'

Any suggestions?


Solution

  • Answer: no reason at all.

    sudo reboot now
    

    And it worked. Any comments as to why might be appreciated by future developers.