lib/openwfe/expool/wfidgen.rb in openwferu-0.9.10.653 vs lib/openwfe/expool/wfidgen.rb in openwferu-0.9.11
- old
+ new
@@ -63,18 +63,11 @@
@last_fn = OpenWFE::get_work_directory + '/wfidgen.last'
load_last()
- begin
- @last_f = File.open(@last_fn, "w+")
- rescue Exception => e
- lwarn do
- "new() failed to open #{@last_fn}, continuing anyway...\n"+
- OpenWFE::exception_to_s(e)
- end
- end
+ ensure_last_f
end
#
# Returns a new workflow instance id
#
@@ -122,21 +115,37 @@
# Stops this service.
# In this particular implementation, makes sure the "wfidgen.last"
# file is closed.
#
def stop
+ #linfo { "stop() stopping '#{@service_name}'" }
@last_f.close if @last_f
end
protected
+ def ensure_last_f
+ if (not @last_f) or @last_f.closed?
+ begin
+ @last_f = File.open(@last_fn, "w+")
+ rescue Exception => e
+ lwarn do
+ "new() failed to open #{@last_fn}, "+
+ "continuing anyway...\n"+
+ OpenWFE::exception_to_s(e)
+ end
+ end
+ end
+ end
+
def now
wfid = Time.now.to_f * 1000 * 10
wfid.to_i
end
def save_last
return unless @last_f
+ ensure_last_f()
@last_f.pos = 0
@last_f.puts @last
end
def load_last