# Script/runner inside BackgrounDRb worker

**URL:** <https://www.ruby-forum.com/t/script-runner-inside-backgroundrb-worker/108929>\
**Category:** Rails\
**Created:** [July 9, 2007, 5:05pm UTC](https://www.ruby-forum.com/t/script-runner-inside-backgroundrb-worker/108929 "2007-07-09T17:05:47Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![joep](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/87869e/32.png) [@joep](https://www.ruby-forum.com/u/joep)\
**Post date:** [July 9, 2007, 5:05pm UTC](https://www.ruby-forum.com/t/script-runner-inside-backgroundrb-worker/108929/1 "2007-07-09T17:05:47Z")

</div>

How can I do this?

When I try “rake backgroundrb:start” now, I get this error:  
/usr/lib/ruby/1.8/rubygems/custom\_require.rb:27:in  
`gem\_original\_require’:  
/home/joe/projects/edu/config/…/script/backgroundrb/…/…/config/…/lib/workers/mailman\_worker.rb:14:  
syntax error, unexpected tSTRING\_BEG, expecting kDO or ‘{’ or ‘(’  
(SyntaxError)  
script/runner ‘MailQueue.process’ -e development

Here is my worker:  
class MailmanWorker \< BackgrounDRb::Rails

repeat\_every 5.minutes  
first\_run Time.now

def do\_work(args)  
## This will send all the emails in the queued\_mails table  
script/runner ‘MailQueue.process’ -e development  
kill()  
end

end

---

<div class="post-metadata">

**Author:** ![joep](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/87869e/32.png) [@joep](https://www.ruby-forum.com/u/joep)\
**Post date:** [July 9, 2007, 8:07pm UTC](https://www.ruby-forum.com/t/script-runner-inside-backgroundrb-worker/108929/2 "2007-07-09T20:07:08Z")

</div>

> When I try “rake backgroundrb:start” now, I get this error:  
> /usr/lib/ruby/1.8/rubygems/custom\_require.rb:27:in  
> `gem\_original\_require’:  
> /home/joe/projects/edu/config/…/script/backgroundrb/…/…/config/…/lib/workers/mailman\_worker.rb:14:  
> syntax error, unexpected tSTRING\_BEG, expecting kDO or ‘{’ or ‘(’  
> (SyntaxError)  
> script/runner ‘MailQueue.process’ -e development  
> . ^

Do I not need the “script/runner” part if it’s inside a worker? How  
would I call this?

---

<div class="post-metadata">

**Author:** ![joep](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/87869e/32.png) [@joep](https://www.ruby-forum.com/u/joep)\
**Post date:** [July 9, 2007, 8:13pm UTC](https://www.ruby-forum.com/t/script-runner-inside-backgroundrb-worker/108929/3 "2007-07-09T20:13:35Z")

</div>

Joe P. wrote the following on 09.07.2007 17:05 :

> Here is my worker:  
> class MailmanWorker \< BackgrounDRb::Rails
> 
> repeat\_every 5.minutes  
> first\_run Time.now
> 
> def do\_work(args)  
> ## This will send all the emails in the queued\_mails table  
> script/runner ‘MailQueue.process’ -e development

You are trying a syntax fitted for a shell script in a ruby script…

Just use “MailQueue.process”.

> ```
> kill()
> 
> ```

Not sure what it is supposed to do (but I’m not familiar with  
BackgrounDRB).

> end
> 
> end

Anyway, as the cron-like features of BackgrounDRB are reported to be  
highly unstable, you’d probably just use cron (and in this case you’ll  
have to use your original syntax with script/runner)

Good luck,

Lionel

---

<div class="post-metadata">

**Author:** ![joep](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/87869e/32.png) [@joep](https://www.ruby-forum.com/u/joep)\
**Post date:** [July 9, 2007, 10:31pm UTC](https://www.ruby-forum.com/t/script-runner-inside-backgroundrb-worker/108929/4 "2007-07-09T22:31:51Z")

</div>

I haven’t heard anything bad about the BackgrounDRB cron features. I  
was  
actually going to switch over to it… Where did you read that the cron  
feature was unstable? Thanks,  
Ben

---

<div class="post-metadata">

**Author:** ![joep](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/87869e/32.png) [@joep](https://www.ruby-forum.com/u/joep)\
**Post date:** [July 9, 2007, 11:31pm UTC](https://www.ruby-forum.com/t/script-runner-inside-backgroundrb-worker/108929/5 "2007-07-09T23:31:56Z")

</div>

On 9-Jul-07, at 5:17 PM, Lionel B. wrote:

> 000915.html  
> Lionel  
> As I’ve posted problems with brb here before, so it’s apropos that I  
> note a solution I’ve found to an instability.

I’ve found that within (potentially) very short running processes  
putting a sleep 5 (or so) at the beginning seems to clean up internal  
brb crashes; perhaps not all, but I’m now smiling much more. Brb has  
now been running 3 days without failure. Not putting the worker to  
sleep would result in 2-3 crashes per 24 hours.

When I can free up a few days I’ll likely dig into brb myself.

cheers,

Jodi

---

<div class="post-metadata">

**Author:** ![joep](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/87869e/32.png) [@joep](https://www.ruby-forum.com/u/joep)\
**Post date:** [July 9, 2007, 11:17pm UTC](https://www.ruby-forum.com/t/script-runner-inside-backgroundrb-worker/108929/6 "2007-07-09T23:17:56Z")

</div>

Ben M. wrote the following on 09.07.2007 22:31 :

> I haven’t heard anything bad about the BackgrounDRB cron features. I  
> was actually going to switch over to it… Where did you read that the  
> cron feature was unstable? Thanks,  
> Ben

Posts on the backgroundrb-devel mailing-list.  
[http://rubyforge.org/pipermail/backgroundrb-devel/2007-June/000915.html](http://rubyforge.org/pipermail/backgroundrb-devel/2007-June/000915.html)

It seems cron-like feature could fit in backgroundrb but are not yet  
stable.

I always read the -users and -devel lists before deciding to use  
software in production and backgroundrb is on my radar since some  
time…

Regards,

Lionel

---

<div class="post-metadata">

**Author:** ![joep](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/87869e/32.png) [@joep](https://www.ruby-forum.com/u/joep)\
**Post date:** [July 9, 2007, 11:39pm UTC](https://www.ruby-forum.com/t/script-runner-inside-backgroundrb-worker/108929/7 "2007-07-09T23:39:58Z")

</div>

On Jul 9, 2007, at 2:31 PM, Jodi S. wrote:

> > > cron feature was unstable? Thanks,  
> > > software in production and backgroundrb is on my radar since some  
> > > I’ve found that within (potentially) very short running processes  
> > > putting a sleep 5 (or so) at the beginning seems to clean up internal  
> > > brb crashes; perhaps not all, but I’m now smiling much more. Brb has  
> > > now been running 3 days without failure. Not putting the worker to  
> > > sleep would result in 2-3 crashes per 24 hours.
> 
> When I can free up a few days I’ll likely dig into brb myself.
> 
> cheers,
> 
> Jodi

Yeah unfortunately I haven’t had any time to work on bdrb in a long  
time. I am going to put a call out for a new maintainer as I will not  
have time to support the library properly in the future. It’s got aq  
good start to being a great project so if anyone wants to step up and  
take over as maintainer I’d be happy to help wityh the process.

Cheers-  
– Ezra Z.  
– Lead Rails Evangelist  
– removed\_email\_address@domain.invalid  
– Engine Y., Serious Rails Hosting  
– (866) 518-YARD (9273)
