Rufus job that mysteriously doesn't run (Debian, Rails, Passenger)

527 views
Skip to first unread message

Marcus

unread,
Feb 21, 2009, 12:27:05 PM2/21/09
to Rufus Ruby
I have a small rails app with a simple task that runs fine on 2 OS X
machines, but I can't get it to run under Passenger on Debian (using
either enterprise ruby or regular ruby 1.8.6). I can start it on the
same machine using script/server production and it runs... when I run
it using Passenger the job is created fine, it just does not run... it
also throws no errors (that I've found) making it tough to debug.

I could use some suggestions for where else to look to debug or if
anyone's come across something similar, that'd be great.

This is the job:

scheduler = Rufus::Scheduler.start_new
ActiveRecord::Base.logger.info("Starting")

scheduler.every("15s") do
ActiveRecord::Base.logger.info("Alert from scheduler #{Time.now}")
end

ActiveRecord::Base.logger.info(scheduler.to_yaml)

Running it under Passenger prints the following to the log (and then
prints nothing every 15s thereafter):

Starting
(?) --- &id001 !ruby/object:Rufus::Scheduler
cron_jobs: {}

exit_when_no_more_jobs: false
last_cron_second: 52
non_cron_jobs:
0: !ruby/object:Rufus::EveryJob
at: 1235236867.7779
block: !ruby/object:Proc {}

job_id: 0
params:
:every: 15s
scheduler: *id001
tags: []

pending_jobs: []

precision: 0.25
schedule_queue: !ruby/object:Queue {}

scheduler_thread: !ruby/object:Thread {}

stopped: false
thread_name: rufus scheduler
unschedule_queue: !ruby/object:Queue {}

John Mettraux

unread,
Feb 21, 2009, 11:09:46 PM2/21/09
to rufus...@googlegroups.com
On Sun, Feb 22, 2009 at 2:27 AM, Marcus <vorw...@gmail.com> wrote:
>
> I have a small rails app with a simple task that runs fine on 2 OS X
> machines, but I can't get it to run under Passenger on Debian (using
> either enterprise ruby or regular ruby 1.8.6). I can start it on the
> same machine using script/server production and it runs... when I run
> it using Passenger the job is created fine, it just does not run... it
> also throws no errors (that I've found) making it tough to debug.
>
> I could use some suggestions for where else to look to debug or if
> anyone's come across something similar, that'd be great.

Hello Marcus,

this reminds me of

http://groups.google.com/group/rufus-ruby/browse_frm/thread/3583f4a29820e673

There is an interest for passenger...


I'm installing passenger right now.


I was wondering what happens on your passenger with things like :

---8<---
Thread.new do
ActiveRecord::Base.logger.info("Doctor Schweizer, it's now #{Time.now}")
sleep 15
end
--->8---

Let's also have a look at the passenger mailing lists.


Best regards,

--
John Mettraux - http://jmettraux.wordpress.com

John Mettraux

unread,
Feb 22, 2009, 12:12:50 AM2/22/09
to rufus...@googlegroups.com
On Sun, Feb 22, 2009 at 1:09 PM, John Mettraux <jmet...@openwfe.org> wrote:
> On Sun, Feb 22, 2009 at 2:27 AM, Marcus <vorw...@gmail.com> wrote:
>>
>> I have a small rails app with a simple task that runs fine on 2 OS X
>> machines, but I can't get it to run under Passenger on Debian (using
>> either enterprise ruby or regular ruby 1.8.6). I can start it on the
>> same machine using script/server production and it runs... when I run
>> it using Passenger the job is created fine, it just does not run... it
>> also throws no errors (that I've found) making it tough to debug.
>>
>> I could use some suggestions for where else to look to debug or if
>> anyone's come across something similar, that'd be great.

So, I installed passenger and created an app with this initializer :

---8<---
ActiveRecord::Base.logger.info("scheduling...")

Thread.new do
ActiveRecord::Base.logger.info("it's #{Time.now}")
sleep 10
end

ActiveRecord::Base.logger.info("scheduled...")
--->8---

"ing" and "ed" appeared in the log, but then nothing else.

Passenger seems to simply disregards Ruby threads.

I had the same result with Passenger + Ruby Enterprise Edition.


I then tried this :

---8<---
ActiveRecord::Base.logger.info("scheduling...")

Thread.abort_on_exception = true
begin
Thread.new do
ActiveRecord::Base.logger.info("it's #{Time.now}")
sleep 10
end
rescue Exception => e
ActiveRecord::Base.logger.info("scheduling failed\n#{e}")
end

ActiveRecord::Base.logger.info("scheduled...")
--->8---

Same result, "scheduling...\nscheduled..." and nothing more.


I guess you'll have to rely on cron and at for your scheduling. Have a
look at this nice project :

http://github.com/javan/whenever/


Passenger is great BTW.

Marcus

unread,
Feb 22, 2009, 11:51:13 AM2/22/09
to Rufus Ruby
John,
Thanks for taking the time to look into it. Interesting that it works
in Passenger in development mode, but not production. Since I first
posted I (like you mentioned) set up a cron job and that's working
fine, maybe not as fun as Rufus Scheduler, but functional :)

Thanks again,
Marcus

On Feb 21, 9:12 pm, John Mettraux <jmettr...@openwfe.org> wrote:
> On Sun, Feb 22, 2009 at 1:09 PM, John Mettraux <jmettr...@openwfe.org> wrote:
Reply all
Reply to author
Forward
0 new messages