Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
how to release the rufus process
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  9 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
edward  
View profile  
 More options Aug 24 2012, 5:10 am
From: edward <ajax....@gmail.com>
Date: Fri, 24 Aug 2012 02:10:45 -0700 (PDT)
Local: Fri, Aug 24 2012 5:10 am
Subject: how to release the rufus process

Hello everybody
I need to compile a ruby script into a window exe file using OCRA, in my
script, I used fufus to execute a scheduler task, including
scheduler.every...  
scheduler cron...
I use job.unschedule to unload the scheuler, but the process is still live.
so the OCRA could not get all script informaiton.  until the whole process
is done.
my question is:
how to stop or release the script/process?
Any help would be great appreciate.

Edward


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
John Mettraux  
View profile  
 More options Aug 24 2012, 5:13 am
From: John Mettraux <jmettr...@gmail.com>
Date: Fri, 24 Aug 2012 18:13:11 +0900
Local: Fri, Aug 24 2012 5:13 am
Subject: Re: [rufus:755] how to release the rufus process

On Fri, Aug 24, 2012 at 02:10:45AM -0700, edward wrote:

> I need to compile a ruby script into a window exe file using OCRA, in my
> script, I used fufus to execute a scheduler task, including
> scheduler.every...
> scheduler cron...
> I use job.unschedule to unload the scheuler, but the process is still live.
> so the OCRA could not get all script informaiton.  until the whole process
> is done.
> my question is:
> how to stop or release the script/process?
> Any help would be great appreciate.

Hello,

you can do

  exit(0)

to exit the process (and of course terminate the scheduler).

Hope it helps, best regards,

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


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
edward  
View profile  
 More options Aug 24 2012, 6:28 am
From: edward <ajax....@gmail.com>
Date: Fri, 24 Aug 2012 03:28:24 -0700 (PDT)
Local: Fri, Aug 24 2012 6:28 am
Subject: Re: [rufus:755] how to release the rufus process

Thanks for your so quickly reply, John.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
edward  
View profile  
 More options Aug 24 2012, 6:57 am
From: edward <ajax....@gmail.com>
Date: Fri, 24 Aug 2012 03:57:26 -0700 (PDT)
Local: Fri, Aug 24 2012 6:57 am
Subject: Re: [rufus:755] how to release the rufus process

Dear John
where is the place to put [exit(0)]?

the following is my script:
-----<8----
def time_format(t) ;t.strftime("%Y-%m-%d %a %H:%M") ;end

begin
scheduler = Rufus::Scheduler.start_new
i=0
scheduler.every '30s' do |job|
shut_time=time_format(Time.now)
 p shut_time
if shut_time =="2012-08-24 Fri 18:53"
    puts "crop is ready #{i}."
    job.unschedule
    Process.exit(0)
  else
    i+=1
    puts "crop not yet ready..#{i}."
  end
end
scheduler.join
end
-------->8--------
it caused a "scheduler caught exception:"

Cheers
Edward


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
John Mettraux  
View profile  
 More options Aug 24 2012, 7:24 am
From: John Mettraux <jmettr...@gmail.com>
Date: Fri, 24 Aug 2012 20:24:37 +0900
Local: Fri, Aug 24 2012 7:24 am
Subject: Re: [rufus:758] how to release the rufus process

Hello,

too bad you didn't mention what exception got caught.

Two variants, a:

---8<----
require 'rufus-scheduler'

def time_format(t); t.strftime("%Y-%m-%d %a %H:%M"); end

scheduler = Rufus::Scheduler.start_new

def scheduler.handle_exception(job, exception)
  exit(0) if exception.is_a?(SystemExit)
  p [ job, exception ]
end

i = 0

scheduler.every '30s' do |job|
  shut_time = time_format(Time.now)
  p shut_time
  if shut_time == "2012-08-24 Fri 18:53"
    puts "crop is ready #{i}."
    #job.unschedule # no need to unschedule if we exit
    Process.exit(0)
  end
  i += 1
  puts "crop not yet ready..#{i}."
end
scheduler.join
--->8---

b:

---8<----
require 'rufus-scheduler'

def time_format(t); t.strftime("%Y-%m-%d %a %H:%M"); end

scheduler = Rufus::Scheduler.start_new

def scheduler.handle_exception(job, exception)
  exit(0) if exception.message == 'over.'
  p [ job, exception ]
end

i = 0

scheduler.every '30s' do |job|
  shut_time = time_format(Time.now)
  p shut_time
  if shut_time == "2012-08-24 Fri 18:53"
    puts "crop is ready #{i}."
    #job.unschedule # no need to unschedule if we exit
    raise "over."
  end
  i += 1
  puts "crop not yet ready..#{i}."
end
scheduler.join
--->8---

And a third variant, because I think it's overkill to use rufus-scheduler for
that:

---8<---
require 'time'
  # to enable Time.parse(s)

shutdown_time = Time.parse('2012-08-24 Fri 18:53')
i = 0

loop do

  sleep 30

  if Time.now >= shutdown_time
    puts "#{Time.now} - crop is ready #{i}."
    break
  end

  i = i + 1
  puts "#{Time.now} - crop not yet ready..#{i}."
end
--->8---

Best regards,

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


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
edwar li  
View profile  
 More options Aug 24 2012, 7:29 pm
From: edwar li <ajax....@gmail.com>
Date: Sat, 25 Aug 2012 07:29:51 +0800
Local: Fri, Aug 24 2012 7:29 pm
Subject: Re: [rufus:755] how to release the rufus process

Thank you very much for your very detail scripts,John.

在 2012年8月24日星期五,John Mettraux 写道:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Eric Platon  
View profile  
 More options Nov 7 2012, 4:31 am
From: Eric Platon <zar...@gmx.com>
Date: Wed, 7 Nov 2012 01:31:37 -0800 (PST)
Local: Wed, Nov 7 2012 4:31 am
Subject: Re: [rufus:758] how to release the rufus process

Jown, Edward,

Does any of the two alternative actually work? As for version 2.0.18, none
worked for me. The reason they do not work is that the exit / Process.exitraise a
SystemExit that Rufus evaluates as an error in the exception handler:

In lib/rufus/sc/scheduler.rb:
---
   def do_handle_exception(job, exception)

      begin

        [ :log_exception, :handle_exception, :on_exception ].each do |m|

          next unless self.respond_to?(m)

          if method(m).arity == 1
            self.send(m, exception)
          else
            self.send(m, job, exception)
          end

          return
            # exception was handled successfully
        end

      rescue Exception => e

        $stderr.puts '*' * 80
        $stderr.puts 'the exception handling method itself had an issue:'
        $stderr.puts e
        $stderr.puts *e.backtrace
        $stderr.puts '*' * 80
      end

      $stderr.puts '=' * 80
      $stderr.puts 'scheduler caught exception:'
      $stderr.puts exception
      $stderr.puts *exception.backtrace
      $stderr.puts '=' * 80
    end
---

The rescue catches all exceptions, including SystemExit.

Eric


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
John Mettraux  
View profile  
 More options Nov 7 2012, 4:38 am
From: John Mettraux <jmettr...@gmail.com>
Date: Wed, 7 Nov 2012 18:38:46 +0900
Local: Wed, Nov 7 2012 4:38 am
Subject: Re: [rufus:765] how to release the rufus process

On Wed, Nov 07, 2012 at 01:31:37AM -0800, Eric Platon wrote:

> Does any of the two alternative actually work? As for version 2.0.18, none
> worked for me. The reason they do not work is that the exit / Process.exitraise a
> SystemExit that Rufus evaluates as an error in the exception handler:

> In lib/rufus/sc/scheduler.rb:

> (...)

> The rescue catches all exceptions, including SystemExit.

Salut Eric,

glad to read from you.

Yes this rescue is "excessive", been thinking about removing it for a while,
but nobody complained [too much].

I'd be willing to be a good citizen and rescue the default (StandardError)
and let Exception go through.

What do you guys think?

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


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Brandon  
View profile  
 More options Nov 29 2012, 10:17 am
From: Brandon <metrix1...@gmail.com>
Date: Thu, 29 Nov 2012 07:17:01 -0800 (PST)
Local: Thurs, Nov 29 2012 10:17 am
Subject: Re: [rufus:765] how to release the rufus process

This would be very helpful for me.  I am trying to use Rufus from a Windows
daemon and cannot get the application to exit when the service is stopped.  

Brandon


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »