Search code examples
ruby-on-railsupstartforeman

Upstart task generated by foreman doesn't find file?


I used foreman to export my Procfile to an upstart task.

Procfile:

web: bundle exec rails server
websocket: bundle exec rails runner websocket-server/em_websocket.rb

One of the upstart tasks (they are very alike and fail with the same error):

start on starting app-web
stop on stopping app-web
respawn

env PORT=5000

setuid app

chdir /var/www/app

exec bundle exec rails server

And the error (I got it via dmesg):

[35207.676836] init: Failed to spawn app-websocket-1 main process: unable to execute: No such file or directory
[35207.679577] init: Failed to spawn app-web-1 main process: unable to execute: No such file or directory

When I switch to the app user, I am actually able to run bundle exec rails server from the given directory.

Is there any way to pin down the error a little more? I didn't find any related logs in /var/log/upstart/.


Solution

  • If you installed ruby via RVM it may be possible that the init is run before the rvm script runs. Did you try using absolute references to the bundle bin?

    whereis bundle 
    

    to obtain it

    RVM was apparently not initialized or is not available in the upstart enviroment. Luckily rvm has wrappers for this case: https://rvm.io/integration/init-d