0

I've a Rails server that runs flawless at the moment (Ruby Enterprise + Passenger + Apache).

It should also to run some independent ruby scripts (setting up localhost XML-RPC servers) on the background. What is the best way to do this?

Thanks in advance!

2
  • 1
    Maybe [this][1] question would be helpful? [1]: stackoverflow.com/questions/388016/… EDIT: Okay, I have no idea why this made this as a comment... Commented Jul 18, 2011 at 20:03
  • well found :) thanks.. i'm gonna try starling Commented Jul 18, 2011 at 20:07

3 Answers 3

1

Consider using Foreman. It allows you to specify your background processes in a simple, text-based Procfile and run them with foreman start.

If you are looking to start your web server and background scripts together with one command, and you're okay with using Passenger Standalone, your Procfile might look something like:

web:    passenger start
rpc:    ruby rpc_server.rb
worker: script/delayed_job
Sign up to request clarification or add additional context in comments.

1 Comment

-this looks much simpler indeed. Do you have any pointers how a procfile looks like? Can find a few very basic examples, but not how the real syntax of the procfile looks like-...EDIT: found a good article at devcenter.heroku.com/articles/procfile
0

I've tried Starling/Workling and found them difficult to configure and keep running as compared to delayed_job. In any case, you'll need a process monitor like God or Monit to make sure whatever solution you choose remains running.

Comments

0

The link in the comments to another question (by Smar, thanks):

http://railscasts.com/episodes/127-rake-in-background

seemed to work fine for me. I didn't need Foreman or any other tool.

I just needed to add this to the Rakefile:

desc "Start some other jobs"
task :start_other_jobs do
    system "ruby job1.rb &"
    system "ruby job2.rb &"
end

(note the ampersand to make it run as a background task)

and then start it by

rake start_other_jobs

Easy, isn't it? :D

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.