A tool for measuring the coverage of Bluesky/ATProto relays

stop worker processes after a configured duration

+18 -7
+18 -7
run_test.rb
··· 9 9 config = YAML.load(File.read(SOURCES)) 10 10 11 11 relays = config['relays'] 12 + duration = config['duration']&.to_i || 60 * 15 12 13 maxlen = relays.map(&:length).max 14 + 15 + Worker = Struct.new(:host, :pid) 16 + workers = [] 13 17 14 18 relays.each do |host| 15 19 pid = fork do ··· 30 34 end 31 35 end 32 36 33 - sky.on_connecting { puts "[#{Time.now}] #{host}: Connecting..."} 34 - sky.on_connect { puts "[#{Time.now}] #{host}: Connected ✓"} 35 - 36 - trap("SIGINT") { 37 - sky.disconnect 38 - } 37 + sky.on_connecting { puts "[#{Time.now}] #{host}: Connecting..." } 38 + sky.on_connect { puts "[#{Time.now}] #{host}: Connected ✓" } 39 + 40 + trap('SIGINT') { sky.disconnect } 39 41 40 42 sky.connect 41 43 puts "[#{Time.now}] #{host}: Finished." 42 44 end 45 + 46 + workers << Worker.new(host, pid) 43 47 end 44 48 45 49 begin 46 - sleep 1000000 50 + sleep(duration) 51 + 52 + Process.kill('SIGINT', *workers.map(&:pid)) 53 + 54 + while !workers.empty? 55 + pid = Process.wait 56 + workers.delete_if { |w| w.pid == pid } 57 + end 47 58 rescue Interrupt 48 59 puts 49 60 puts "Stopping..."