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.
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).
On Friday, August 24, 2012 5:13:11 PM UTC+8, John Mettraux wrote:
> 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).
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:"
On Friday, August 24, 2012 6:28:24 PM UTC+8, edward wrote:
> Thanks for your so quickly reply, John.
> On Friday, August 24, 2012 5:13:11 PM UTC+8, John Mettraux wrote:
>> 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).
On Fri, Aug 24, 2012 at 03:57:26AM -0700, edward wrote:
> 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--------
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---
> On Fri, Aug 24, 2012 at 03:57:26AM -0700, edward wrote:
> > 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--------
> 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---
> --
> you received this message because you are subscribed to the "rufus ruby"
> group.
> to post : send email to rufus-ruby@googlegroups.com <javascript:;>
> to unsubscribe : send email to rufus-ruby+unsubscribe@googlegroups.com<javascript:;>
> more options : http://groups.google.com/group/rufus-ruby?hl=en
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
On Friday, August 24, 2012 8:24:37 PM UTC+9, John Mettraux wrote:
> On Fri, Aug 24, 2012 at 03:57:26AM -0700, edward wrote:
> > 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--------
> 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---
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.
On Wednesday, November 7, 2012 3:38:52 AM UTC-6, John Mettraux wrote:
> 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.