Groups keyboard shortcuts have been updated
Dismiss
See shortcuts

Rufus scheduler without passenger

466 views
Skip to first unread message

aavinash.behera

unread,
Sep 3, 2013, 1:36:56 AM9/3/13
to rufus...@googlegroups.com
Hello,

I am trying to use Rufus-Scheduler in my rails app in Azure.
I am using Ruby(1.9.3) & Rails(3.2.8) & Thin server in my rails app.

Is it necessary to use Phusion Passenger ?
Will rufus scheduler not work without it?
I am not able to start the scheduler. What am I doing wrong?

My code - 

require 'rubygems'
require 'rufus/scheduler'
scheduler = Rufus::Scheduler.start_new

scheduler.cron '00 9 * * *' do
     UserMailer.daily_message_report("some email").deliver
  end


Thanks, 
Avinash

John Mettraux

unread,
Sep 3, 2013, 2:14:51 AM9/3/13
to rufus...@googlegroups.com

Hello,

welcome to the rufus mailing list.

On Mon, Sep 02, 2013 at 10:36:56PM -0700, aavinash.behera wrote:
>
> I am trying to use Rufus-Scheduler in my rails app in Azure.
> I am using Ruby(1.9.3) & Rails(3.2.8) & Thin server in my rails app.
>
> Is it necessary to use Phusion Passenger ?

No, not at all.

What makes you think so?

> Will rufus scheduler not work without it?

Rufus-scheduler is a ruby library. It has nothing to do with Passenger. It's
meant to work on any decent Ruby implementation.


> I am not able to start the scheduler. What am I doing wrong?
>
> My code -
>
> require 'rubygems'
> require 'rufus/scheduler'
> scheduler = Rufus::Scheduler.start_new
>
> scheduler.cron '00 9 * * *' do
> UserMailer.daily_message_report("some email").deliver
> end

Try to add this line:

---8<---
scheduler.join
--->8---

at the end of your script, so that it doesn't exit.

If that doesn't work, please say so and explain a bit further.


Best regards,

--
John Mettraux - http://lambda.io/jmettraux

aavinash.behera

unread,
Sep 3, 2013, 2:44:16 AM9/3/13
to rufus...@googlegroups.com
In local it is working fine.
It automatically generated 3 files :-
.rufus-scheduler.rb.swn
.rufus-scheduler.rb.swo
.rufus-scheduler.rb.swp

Even in local I am starting in production(rails s -e production) mode, its working.
Only when i do "rails s -e production -d" it stops working.

& in Azure server I have deployed my rails app. It didnt generate those 3 files as above.
I have done the same things what I did in local. I dont know why its not working even in production mode.


On Tuesday, September 3, 2013 11:44:51 AM UTC+5:30, John Mettraux wrote:

Hello,

welcome to the rufus mailing list.

On Mon, Sep 02, 2013 at 10:36:56PM -0700, aavinash.behera wrote:
>
> I am trying to use Rufus-Scheduler in my rails app in Azure.
> I am using Ruby(1.9.3) & Rails(3.2.8) & Thin server in my rails app.
>
> Is it necessary to use Phusion Passenger ?

No, not at all.

What makes you think so?

In some pages while googling that i have read, some are suggesting to use phusion passenger to make it work.

John Mettraux

unread,
Sep 3, 2013, 2:56:07 AM9/3/13
to rufus...@googlegroups.com

On Mon, Sep 02, 2013 at 11:44:16PM -0700, aavinash.behera wrote:
>
> In local it is working fine.
> It automatically generated 3 files :-
> .rufus-scheduler.rb.swn
> .rufus-scheduler.rb.swo
> .rufus-scheduler.rb.swp
>
> Even in local I am starting in production(rails s -e production) mode, its
> working.
> Only when i do "rails s -e production -d" it stops working.
>
> & in Azure server I have deployed my rails app. It didnt generate those 3
> files as above.
> I have done the same things what I did in local. I dont know why its not
> working even in production mode.

Hello,

are you trying to tell me that in local you are not using Passenger but you
do in production ?

John

aavinash.behera

unread,
Sep 3, 2013, 3:12:54 AM9/3/13
to rufus...@googlegroups.com
No, I am not using passenger.
The problem is - In local, scheduler is working fine. Only not working when I start in daemon mode.
I am not able to make it work in Azure server. The scheduler is not being invoked here. 

Do I need to do any configuration in Azure server for Rufus-scheduler?
 
 

John

John Mettraux

unread,
Sep 3, 2013, 3:19:47 AM9/3/13
to rufus...@googlegroups.com

On Tue, Sep 03, 2013 at 12:12:54AM -0700, aavinash.behera wrote:
>
> No, I am not using passenger.

So, what are you using?

> The problem is - In local, scheduler is working fine. Only not working when
> I start in daemon mode.
> I am not able to make it work in Azure server. The scheduler is not being
> invoked here.

OK.

> Do I need to do any configuration in Azure server for Rufus-scheduler?

Sorry, I don't know anything about Azure server.

Could you please read https://gist.github.com/jmettraux/310fed75f568fd731814

Then please give me details about your production environment.

I cannot tell you now because you are not telling me what server you use in
production (and perhaps I cannot tell you).

If you could give me the link that says "rufus-scheduler works better with
Passenger"... I'd love to read that piece.

aavinash.behera

unread,
Sep 3, 2013, 3:41:08 AM9/3/13
to rufus...@googlegroups.com


On Tuesday, September 3, 2013 12:49:47 PM UTC+5:30, John Mettraux wrote:

On Tue, Sep 03, 2013 at 12:12:54AM -0700, aavinash.behera wrote:
>
> No, I am not using passenger.

So, what are you using?

Ubuntu 12.10 - Same in local & in production.
Thin (1.5.1 codename Straight Razor) - Same in local & in production.
Rails 3.2.8 - Same in local & in production.
Ruby ruby 1.9.3p194(2012-04-20 revision 35410) [i686-linux] in local & ruby 1.9.3p448 (2013-06-27 revision 41675) in production
 

> The problem is - In local, scheduler is working fine. Only not working when
> I start in daemon mode.
> I am not able to make it work in Azure server. The scheduler is not being
> invoked here.

OK.

> Do I need to do any configuration in Azure server for Rufus-scheduler?

Sorry, I don't know anything about Azure server.

 

Sorry. In azure we created an instance where we are deploying our app there.
 

Could you please read https://gist.github.com/jmettraux/310fed75f568fd731814

Then please give me details about your production environment.

I cannot tell you now because you are not telling me what server you use in
production (and perhaps I cannot tell you).

If you could give me the link that says "rufus-scheduler works better with
Passenger"... I'd love to read that piece.

Sorry for this. They were previously using passenger so they have written for passenger.

John Mettraux

unread,
Sep 3, 2013, 3:54:11 AM9/3/13
to rufus...@googlegroups.com

On Tue, Sep 03, 2013 at 12:41:08AM -0700, aavinash.behera wrote:
>
> Ubuntu 12.10 - Same in local & in production.
> Thin (1.5.1 codename Straight Razor) - Same in local & in production.
> Rails 3.2.8 - Same in local & in production.
> Ruby ruby 1.9.3p194(2012-04-20 revision 35410) [i686-linux] in local & ruby
> 1.9.3p448 (2013-06-27 revision 41675) in production

OK.

> > Could you please read
> > https://gist.github.com/jmettraux/310fed75f568fd731814
> >
> > Then please give me details about your production environment.
> >
> > I cannot tell you now because you are not telling me what server you use
> > in
> > production (and perhaps I cannot tell you).
> >
> > If you could give me the link that says "rufus-scheduler works better with
> > Passenger"... I'd love to read that piece.
> >
>
> Sorry for this. They were previously using passenger so they have written
> for passenger.

So the article is not saying that rufus-scheduler works better on Passenger.

Great.


OK.

So this is your code:

```ruby
require 'rubygems'
require 'rufus/scheduler'
scheduler = Rufus::Scheduler.start_new

scheduler.cron '00 9 * * *' do
UserMailer.daily_message_report("some email").deliver
end
```

By the way, where do you put it?

...

Could you please try with?

```ruby
require 'rubygems'
require 'rufus/scheduler'
scheduler = Rufus::Scheduler.start_new

puts "0 - I'm in the schedule file..."

begin
UserMailer.daily_message_report("test email!").deliver
rescue => e
puts "vvv"
puts "cannot deliver mail"
puts
p e
puts e.message
puts
puts e.backtrace
puts "^^^"
end

scheduler.every '1m' do
puts "1 - rufus-scheduler is scheduling..."
end

scheduler.cron '00 9 * * *' do
begin
UserMailer.daily_message_report("some email").deliver
rescue => e
puts "vvv"
puts "something went wrong"
puts
p e
puts e.message
puts
puts e.backtrace
puts "^^^"
end
end
```

I wonder if the message 0 and the message 1 do appear in your console or in
your Rails log.

I wonder if your emails can be delivered...


Waiting for your feedback,

aavinash.behera

unread,
Sep 3, 2013, 4:54:37 AM9/3/13
to rufus...@googlegroups.com
In local it worked for me.
I started the server in my production, it gave me this message - "0 - I'm in the schedule file...". I got the mail also.

After every minute I got this message - "1 - rufus-scheduler is scheduling..."
But it didnt go inside the cron. I didnt receive any mail after.

What is the issue ?

John Mettraux

unread,
Sep 3, 2013, 5:03:29 AM9/3/13
to rufus...@googlegroups.com

On Tue, Sep 03, 2013 at 01:54:37AM -0700, aavinash.behera wrote:
>
> John wrote:
> >
> > Could you please try with?
> >
> > ```ruby
> > require 'rubygems'
> > require 'rufus/scheduler'
> > scheduler = Rufus::Scheduler.start_new
> >
> > puts "0 - I'm in the schedule file..."
> >
> > begin
> > UserMailer.daily_message_report("test email!").deliver
> > rescue => e
> > puts "vvv"
> > puts "cannot deliver mail"
> > puts
> > p e
> > puts e.message
> > puts
> > puts e.backtrace
> > puts "^^^"
> > end
> >
> > scheduler.every '1m' do
> > puts "1 - rufus-scheduler is scheduling..."
> > end
> >
> > scheduler.cron '00 9 * * *' do
> > begin
> > UserMailer.daily_message_report("some email").deliver
> > rescue => e
> > puts "vvv"
> > puts "something went wrong"
> > puts
> > p e
> > puts e.message
> > puts
> > puts e.backtrace
> > puts "^^^"
> > end
> > end
> > ```
>
> In local it worked for me.
> I started the server in my production, it gave me this message - "0 - I'm
> in the schedule file...". I got the mail also.
>
> After every minute I got this message - "1 - rufus-scheduler is
> scheduling..."
> But it didnt go inside the cron. I didnt receive any mail after.
>
> What is the issue ?

That cron means run "every day at 09:00 (am)". When is that for your
development machine? When is that for your production machine? Are they set
for the same time zone?

Do you test by waiting until it's 09:00 am or do you test by setting the next
hour/minute ?

What does

```ruby
scheduler.cron '* * * * *' do
puts "in..., it's #{Time.now} (#{Time.to_f})"
begin
UserMailer.daily_message_report("some email").deliver
rescue => e
puts "vvv"
puts "something went wrong"
puts
p e
puts e.message
puts
puts e.backtrace
puts "^^^"
end
end
```

do ?


Thanks in advance,

avinash behera

unread,
Sep 3, 2013, 6:34:48 AM9/3/13
to rufus...@googlegroups.com
I have changed it manually in scheduler file.
In local it is fine.

Could not test in production either due to our client test the app this time.

Generally Production is in UTC timing. 
So, If i start in rails s -e production, it takes local time in production.
Time.to_f ? it was giving problem in local. (undefined method `to_f' for Time:Class)
 

Do you test by waiting until it's 09:00 am or do you test by setting the next
hour/minute ?

What does

```ruby
scheduler.cron '* * * * *' do
  puts "in..., it's #{Time.now} (#{Time.to_f})"
  begin
    UserMailer.daily_message_report("some email").deliver
  rescue => e
    puts "vvv"
    puts "something went wrong"
    puts
    p e
    puts e.message
    puts
    puts e.backtrace
    puts "^^^"
  end
end
```

do ?


Thanks in advance,

--
John Mettraux   -   http://lambda.io/jmettraux

--
--
you received this message because you are subscribed to the "rufus ruby" group.
to post : send email to rufus...@googlegroups.com
to unsubscribe : send email to rufus-ruby+...@googlegroups.com
more options : http://groups.google.com/group/rufus-ruby?hl=en
---
You received this message because you are subscribed to the Google Groups "Rufus Ruby" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rufus-ruby+...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




John Mettraux

unread,
Sep 3, 2013, 7:22:10 AM9/3/13
to rufus...@googlegroups.com

On Tue, Sep 03, 2013 at 04:04:48PM +0530, avinash behera wrote:
>
> I have changed it manually in scheduler file.
> In local it is fine.

OK.

I guess that by "local" you mean "developement environment".

> Could not test in production either due to our client test the app this
> time.

OK, I guess you'll tell me another time.

> Generally Production is in UTC timing.
> So, If i start in rails s -e production, it takes local time in production.

Ah OK.

> Time.to_f ? it was giving problem in local. (undefined method `to_f' for
> Time:Class)

Sorry about that. I hope you could fix that detail by yourself.


I have the impression that your problem is solved.


Best regards,

avinash behera

unread,
Sep 4, 2013, 5:31:34 AM9/4/13
to rufus...@googlegroups.com
Not yet, Its fine in development(local). But not in production. I am getting the starting mail, but not the one inside scheduler.cron in production.

Any changes need to do in production?

 


Best regards,

--
John Mettraux   -   http://lambda.io/jmettraux

--
--
you received this message because you are subscribed to the "rufus ruby" group.
to post : send email to rufus...@googlegroups.com
to unsubscribe : send email to rufus-ruby+...@googlegroups.com
more options : http://groups.google.com/group/rufus-ruby?hl=en
---
You received this message because you are subscribed to the Google Groups "Rufus Ruby" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rufus-ruby+...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.



--
Thanks,
Avinash

John Mettraux

unread,
Sep 4, 2013, 6:00:44 AM9/4/13
to rufus...@googlegroups.com
On Wed, Sep 04, 2013 at 03:01:34PM +0530, avinash behera wrote:
>
> Not yet, Its fine in development(local). But not in production. I am
> getting the starting mail, but not the one inside scheduler.cron in
> production.
>
> Any changes need to do in production?

Hello,

before thinking about changes in production, could you please indicate me if
the puts "xyz" I have added to the your schedule code get printed.

Thanks for the feedback about the "starting" email, but as you can read, I
added a bunch of puts and I'd like to know if they output...

I would appreciate detailed feedback. Until now your feedback is very vague,
rather unprofessional. Please behave.


Thanks in advance,

aavinash.behera

unread,
Sep 4, 2013, 6:09:02 AM9/4/13
to rufus...@googlegroups.com
Hello,

While starting the production server, I am getting this put :-
0 - I'm in the schedule file... & I am getting the email.

& after every 1 m I am getting this put:-
1 - rufus-scheduler is scheduling...

But it is not going inside scheduler.cron '* * * * *'.

All these in production thin server.


Thanks,
Avinash
Sorry for this.

John Mettraux

unread,
Sep 4, 2013, 6:15:10 AM9/4/13
to rufus...@googlegroups.com

On Wed, Sep 04, 2013 at 03:09:02AM -0700, aavinash.behera wrote:
>
> While starting the production server, I am getting this put :-
> 0 - I'm in the schedule file... & I am getting the email.
>
> & after every 1 m I am getting this put:-
> 1 - rufus-scheduler is scheduling...
>
> But it is not going inside scheduler.cron '* * * * *'.
>
> All these in production thin server.

Hello,

now, please add

```ruby
require 'pp'
def scheduler.on_exception(job, ex)
puts "*** intercepted exception"
pp job
puts
p ex
puts ex.message
puts
puts ex.backtrace
end
```

Right after the scheduler is initialized.

Does it output anything?

aavinash.behera

unread,
Sep 4, 2013, 6:58:08 AM9/4/13
to rufus...@googlegroups.com
Hello,

Now in production, every one minute - puts "1 - rufus-scheduler is scheduling..." appears in console.
& I got the mail with scheduler.cron '* * * * *'
It seems to be working in production also now. 

Is there anything what I can do in daemon mode?
I tried starting in daemon mode - rails s -e production -d in production. It doesn't send me any mail.

John Mettraux

unread,
Sep 4, 2013, 7:23:32 AM9/4/13
to rufus...@googlegroups.com

On Wed, Sep 04, 2013 at 03:58:08AM -0700, aavinash.behera wrote:
>
> Now in production, every one minute - puts "1 - rufus-scheduler is
> scheduling..." appears in console.
> & I got the mail with scheduler.cron '* * * * *'
> It seems to be working in production also now.

Ah, thanks for that very important bit of information.

> Is there anything what I can do in daemon mode?
> I tried starting in daemon mode - rails s -e production -d in production.
> It doesn't send me any mail.>

Try replacing my "puts" with Rails logging statements and then look at what
gets into the Rails logs.


Good luck,
Reply all
Reply to author
Forward
0 new messages