Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master
Fetching contributors…

Cannot retrieve contributors at this time

executable file 59 lines (50 sloc) 1.384 kb
#!/usr/bin/env ruby
require 'timeout'
# The base location of all the scripts
baseloc = "."
# A list of scripts to be executed
scriptlist = ["test1.sh",
"test2.sh",
"test3.sh"]
##########################################################
$threads = []
def shutdown
STDERR.print "Shutting down threads..."
STDERR.flush
begin
Timeout::timeout(10) do
$threads.each { |t|
t.terminate
}
end
rescue Timeout::Error
$threads.each { |t|
t.kill!
}
end
STDERR.puts "Done."
exit(0)
end
trap "SIGTERM", proc {
STDERR.puts "Caught SIGTERM, killing threads and exiting..."
shutdown()
}
begin
if !File.directory?("./logs")
Dir.mkdir("./logs")
end
scriptlist.each { |script|
$threads << Thread.new { $SAFE=1
system("#{baseloc}/#{script} > #{baseloc}/#{script}.stdout.log 2> #{baseloc}/#{script}.stderr.log")
}
puts "Thread spawned for #{script}, see #{baseloc}/#{script}.stdout.log #{baseloc}/#{script}.stderr.log for output"
}
print "Threads processing..."
STDOUT.flush
$threads.each { |t|
t.join
}
puts "Finished."
rescue Interrupt
shutdown()
end
Jump to Line
Something went wrong with that request. Please try again.