1

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:
https://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...

1 Answer 1

5

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.

2
  • upvote. after i verify it working in my implementation i'll give it the check Mar 6, 2012 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") Jul 30, 2015 at 1:33

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .