add silent exit option
This commit is contained in:
parent
20c9388d38
commit
220268d5af
1 changed files with 36 additions and 8 deletions
|
|
@ -1,6 +1,6 @@
|
|||
#!/usr/local/bin/ruby -w
|
||||
|
||||
# $Dwarf: ripnews.rb,v 1.100 2005/02/05 08:27:29 ward Exp $
|
||||
# $Dwarf: ripnews.rb,v 1.101 2005/02/06 13:43:52 ward Exp $
|
||||
# $Source$
|
||||
|
||||
#
|
||||
|
|
@ -147,6 +147,7 @@ def parse_options(options)
|
|||
[ "-L", "--longname", GetoptLong::NO_ARGUMENT ],
|
||||
[ "-C", "--combinedname", GetoptLong::NO_ARGUMENT ],
|
||||
[ "-M", "--multipart", GetoptLong::NO_ARGUMENT ],
|
||||
[ "-s", GetoptLong::NO_ARGUMENT ],
|
||||
[ "-S", "--singlepart", GetoptLong::NO_ARGUMENT ],
|
||||
[ "-T", "--test", GetoptLong::NO_ARGUMENT ],
|
||||
[ "-X", "--exclude", GetoptLong::REQUIRED_ARGUMENT ]
|
||||
|
|
@ -160,7 +161,6 @@ def parse_options(options)
|
|||
print "#{$!}\n"
|
||||
usage
|
||||
end
|
||||
|
||||
return options
|
||||
end
|
||||
|
||||
|
|
@ -172,6 +172,7 @@ def usage
|
|||
print "-L use subject as filename\n"
|
||||
print "-C use combined filenames\n"
|
||||
print "-M get multipart articles\n"
|
||||
print "-s exit silently if already running\n"
|
||||
print "-S get singlepart articles\n"
|
||||
print "-T test mode, don't update newsrc file\n"
|
||||
print "-X <pattern> specify an exclude pattern\n"
|
||||
|
|
@ -179,8 +180,10 @@ def usage
|
|||
end
|
||||
|
||||
def parse_config(default = {})
|
||||
if ! default.has_key?('-s')
|
||||
print "Parsing config\n"
|
||||
print "#{default['-c']}\n"
|
||||
end
|
||||
if FileTest.readable?("#{default['-c']}")
|
||||
file = File.new("#{default['-c']}")
|
||||
lines = file.readlines
|
||||
|
|
@ -321,7 +324,9 @@ def lock
|
|||
pid.chomp!
|
||||
begin
|
||||
Process.kill(0, pid.to_i)
|
||||
if ! @config[group].has_key?('-s')
|
||||
print "Already running, exiting...\n"
|
||||
end
|
||||
exit
|
||||
rescue Errno::ESRCH
|
||||
print "Stale lock found... removing...\n"
|
||||
|
|
@ -472,15 +477,25 @@ def get_multi(subj, group)
|
|||
output_data(tsubj, tmode, tfilename, tbody)
|
||||
end # thread end
|
||||
|
||||
# (0 ... @decode_threads.length).to_a.reverse.each{ |x|
|
||||
# if @decode_threads[x].status == "sleep"
|
||||
# @decode_threads[x].run
|
||||
# elsif @decode_threads[x].status == "false" && @decode_threads[x].join
|
||||
# @decode_threads.delete_at(x)
|
||||
# end
|
||||
# }
|
||||
|
||||
Thread.list.each {|t| p t}
|
||||
@decode_threads.each{ |thr|
|
||||
if thr.status == "sleep" # and fire up the threads again
|
||||
thr.run
|
||||
elsif thr.status == "false" # remove finished threads
|
||||
thr.join
|
||||
# else
|
||||
# p thr.status
|
||||
## p thr.status
|
||||
end
|
||||
}
|
||||
Thread.list.each {|t| p t}
|
||||
puts "ouside thread\n"
|
||||
|
||||
return true
|
||||
|
|
@ -685,10 +700,23 @@ def main
|
|||
end
|
||||
|
||||
# hier wachten op evt. threads...
|
||||
if @decode_threads
|
||||
if ! @decode_threads.empty?
|
||||
@articles.disconnect
|
||||
puts "Waiting for decode threads..."
|
||||
@decode_threads.each{|thr| thr.join}
|
||||
# while @decode_threads
|
||||
# (0 ... @decode_threads.length).to_a.reverse.each{ |x|
|
||||
# if @decode_threads[x].status == "false" && @decode_threads[x].join(0.15)
|
||||
# puts "deleting #{x} from thread pool"
|
||||
# @decode_threads.delete_at(x)
|
||||
# end
|
||||
# }
|
||||
# end
|
||||
Thread.list.each {|t| p t}
|
||||
@decode_threads.each{|thr|
|
||||
p "thr inspect #{thr.inspect}"
|
||||
thr.join
|
||||
}
|
||||
Thread.list.each {|t| p t}
|
||||
puts "Decode threads all done"
|
||||
end
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue