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
|
#!/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$
|
# $Source$
|
||||||
|
|
||||||
#
|
#
|
||||||
|
|
@ -147,6 +147,7 @@ def parse_options(options)
|
||||||
[ "-L", "--longname", GetoptLong::NO_ARGUMENT ],
|
[ "-L", "--longname", GetoptLong::NO_ARGUMENT ],
|
||||||
[ "-C", "--combinedname", GetoptLong::NO_ARGUMENT ],
|
[ "-C", "--combinedname", GetoptLong::NO_ARGUMENT ],
|
||||||
[ "-M", "--multipart", GetoptLong::NO_ARGUMENT ],
|
[ "-M", "--multipart", GetoptLong::NO_ARGUMENT ],
|
||||||
|
[ "-s", GetoptLong::NO_ARGUMENT ],
|
||||||
[ "-S", "--singlepart", GetoptLong::NO_ARGUMENT ],
|
[ "-S", "--singlepart", GetoptLong::NO_ARGUMENT ],
|
||||||
[ "-T", "--test", GetoptLong::NO_ARGUMENT ],
|
[ "-T", "--test", GetoptLong::NO_ARGUMENT ],
|
||||||
[ "-X", "--exclude", GetoptLong::REQUIRED_ARGUMENT ]
|
[ "-X", "--exclude", GetoptLong::REQUIRED_ARGUMENT ]
|
||||||
|
|
@ -160,7 +161,6 @@ def parse_options(options)
|
||||||
print "#{$!}\n"
|
print "#{$!}\n"
|
||||||
usage
|
usage
|
||||||
end
|
end
|
||||||
|
|
||||||
return options
|
return options
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
@ -172,6 +172,7 @@ def usage
|
||||||
print "-L use subject as filename\n"
|
print "-L use subject as filename\n"
|
||||||
print "-C use combined filenames\n"
|
print "-C use combined filenames\n"
|
||||||
print "-M get multipart articles\n"
|
print "-M get multipart articles\n"
|
||||||
|
print "-s exit silently if already running\n"
|
||||||
print "-S get singlepart articles\n"
|
print "-S get singlepart articles\n"
|
||||||
print "-T test mode, don't update newsrc file\n"
|
print "-T test mode, don't update newsrc file\n"
|
||||||
print "-X <pattern> specify an exclude pattern\n"
|
print "-X <pattern> specify an exclude pattern\n"
|
||||||
|
|
@ -179,8 +180,10 @@ def usage
|
||||||
end
|
end
|
||||||
|
|
||||||
def parse_config(default = {})
|
def parse_config(default = {})
|
||||||
print "Parsing config\n"
|
if ! default.has_key?('-s')
|
||||||
print "#{default['-c']}\n"
|
print "Parsing config\n"
|
||||||
|
print "#{default['-c']}\n"
|
||||||
|
end
|
||||||
if FileTest.readable?("#{default['-c']}")
|
if FileTest.readable?("#{default['-c']}")
|
||||||
file = File.new("#{default['-c']}")
|
file = File.new("#{default['-c']}")
|
||||||
lines = file.readlines
|
lines = file.readlines
|
||||||
|
|
@ -321,7 +324,9 @@ def lock
|
||||||
pid.chomp!
|
pid.chomp!
|
||||||
begin
|
begin
|
||||||
Process.kill(0, pid.to_i)
|
Process.kill(0, pid.to_i)
|
||||||
print "Already running, exiting...\n"
|
if ! @config[group].has_key?('-s')
|
||||||
|
print "Already running, exiting...\n"
|
||||||
|
end
|
||||||
exit
|
exit
|
||||||
rescue Errno::ESRCH
|
rescue Errno::ESRCH
|
||||||
print "Stale lock found... removing...\n"
|
print "Stale lock found... removing...\n"
|
||||||
|
|
@ -472,15 +477,25 @@ def get_multi(subj, group)
|
||||||
output_data(tsubj, tmode, tfilename, tbody)
|
output_data(tsubj, tmode, tfilename, tbody)
|
||||||
end # thread end
|
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|
|
@decode_threads.each{ |thr|
|
||||||
if thr.status == "sleep" # and fire up the threads again
|
if thr.status == "sleep" # and fire up the threads again
|
||||||
thr.run
|
thr.run
|
||||||
elsif thr.status == "false" # remove finished threads
|
elsif thr.status == "false" # remove finished threads
|
||||||
thr.join
|
thr.join
|
||||||
# else
|
# else
|
||||||
# p thr.status
|
## p thr.status
|
||||||
end
|
end
|
||||||
}
|
}
|
||||||
|
Thread.list.each {|t| p t}
|
||||||
puts "ouside thread\n"
|
puts "ouside thread\n"
|
||||||
|
|
||||||
return true
|
return true
|
||||||
|
|
@ -685,10 +700,23 @@ def main
|
||||||
end
|
end
|
||||||
|
|
||||||
# hier wachten op evt. threads...
|
# hier wachten op evt. threads...
|
||||||
if @decode_threads
|
if ! @decode_threads.empty?
|
||||||
@articles.disconnect
|
@articles.disconnect
|
||||||
puts "Waiting for decode threads..."
|
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"
|
puts "Decode threads all done"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue