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/
.
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
You can run bundle in another way. Instead of:
web: bundle exec rails server
You need to run:
web: bash -c '~/.rvm/bin/rvm default do bundle exec rails server'
Note: ~/.rvm/bin/rvm - can be replaced with actual path of rvm installation on your server.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With