Jason Edgecombe
2006-Jul-31 19:19 UTC
[Backgroundrb-devel] Starting backgroundrb from rails and restarting with rails
Hi, I have my rails sites tricked out with capistrano, and backgroundrb, so I can easily use the ant tasks, but I would like to be able to start and stop backgroundrb from within rails. I have a few reasons for this: 1. Using fastcgi, backgroundrb would start under the apache user and the same mod_security context as apache, instead of my developer account which has many more privileges. 2. I''d like rails to be able to start backgroundrb if it isn''t running. 3. I''d also like rails to be to restart backgroundrb if rails itself has been restarted. 4. I''m lazy. ;) I''m thinking of having rails store the time that rails started in backgroundrb and restart backgroundrb if the time if the rails time is later than the backgroundrb time. Any pointers? Thanks, Jason Edgecombe
Charles Brian Quinn
2006-Jul-31 23:03 UTC
[Backgroundrb-devel] Starting backgroundrb from rails and restarting with rails
While I''m not addressing all your issues -- we start backgroundrb using a rake task and leave it running, so we start it up with our rails app, see my previous message to the list. To start under a user, can''t you just chown apache:apache the script/backgroundrb file itself? If you''re capistranoing, I''d put in the after update code or after deploy a task to start it, something like this: desc "Tasks to run after a deploy" task :after_deploy do run("cd #{current_path} && rake backgroundrb:stop") run("cd #{current_path} && rake backgroundrb:start") end And if you anticpate contention problems (i.e. it starting before it''s done stopping), you could put it in a script file with a sleep 5 command in b/t to make sure stop stops it.... p.s. Ezra, maybe we can add backgroundrb:restart and status tasks? hope that helps On 7/31/06, Jason Edgecombe <jedgecombe at carolina.rr.com> wrote:> Hi, > > I have my rails sites tricked out with capistrano, and backgroundrb, so > I can easily use the ant tasks, but I would like to be able to start and > stop backgroundrb from within rails. > > I have a few reasons for this: > 1. Using fastcgi, backgroundrb would start under the apache user and the > same mod_security context as apache, instead of my developer account > which has many more privileges. > 2. I''d like rails to be able to start backgroundrb if it isn''t running. > 3. I''d also like rails to be to restart backgroundrb if rails itself has > been restarted. > 4. I''m lazy. ;) > > I''m thinking of having rails store the time that rails started in > backgroundrb and restart backgroundrb if the time if the rails time is > later than the backgroundrb time. > > Any pointers? > > Thanks, > Jason Edgecombe > > _______________________________________________ > Backgroundrb-devel mailing list > Backgroundrb-devel at rubyforge.org > http://rubyforge.org/mailman/listinfo/backgroundrb-devel >-- Charles Brian Quinn www.seebq.com