Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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:
http://serverfault.com/questions/327965/how-to-start-a-rake-task-using-upstart
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...

share|improve this question
up vote 5 down vote accepted

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>

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

After that, you have to run

initctl reload-configuration

That should do it.

share|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

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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