I can get some random shell script to run as a service...that's not the problem. I think it's related to environment variables given some of the google-ing I did. Either a list of required rails environment variables or a sample rails app running as a service would be helpful.

I found this:
Which is helpful, but it incorporates rvm. I like rvm, but I'm looking for a way to do it without this additional bit of complexity. I may be forced to do it that way though...


Assuming bundle install --deployment --binstubs make sure you create a stub bin/bundle (Bundler does not do this). Then in /etc/init/your-app.conf:

start on started network-services
stop on stopping network-services

<set env variables you need>

pushd <Your app's Gemfile folder>
bin/bundle exec ....
end script

After that, you have to run

initctl reload-configuration

That should do it.

| improve this answer | |
  • upvote. after i verify it working in my implementation i'll give it the check – RobotHumans Mar 6 '12 at 4:12
  • The solution of hedgehog is working fine, but maybe it's worth mentioning that 1. After adding the .conf script to /etc/init you have to run initctl reload-configuration (sorry I'm a newb and didn't know this) 2. the pushd command threw an error in the corresponding log file /var/log/upstart/SERVICE.log and I had to use cd instead (don't know, if this is "bad") – Michael Lihs Jul 30 '15 at 1:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.