1
0
Fork 0
mirror of https://github.com/mperham/sidekiq.git synced 2022-11-09 13:52:34 -05:00
mperham--sidekiq/myapp/Rakefile

59 lines
1.4 KiB
Text
Raw Normal View History

#!/usr/bin/env rake
2016-11-18 17:33:50 -05:00
task :appraise do
failed = false
2016-11-18 17:33:50 -05:00
%w(4 5).each do |ver|
%w(production development).each do |env|
output = `bundle exec ruby integration_setup.rb`
if output.strip != ''
puts output
exit(-1)
end
2016-11-18 17:33:50 -05:00
rout, wout = IO.pipe
rerr, werr = IO.pipe
2016-11-18 17:33:50 -05:00
command = "bundle exec sidekiq"
pid = Process.spawn({'RAILS_ENV' => env, 'BUNDLE_GEMFILE' => "gemfiles/rails_#{ver}.gemfile"},
command, :out => wout, :err => werr)
status = nil
begin
require 'timeout'
Timeout.timeout(10) do
Process.wait(pid)
end
2016-11-18 17:33:50 -05:00
rescue Timeout::Error
puts "Killing #{pid}"
Process.kill('KILL', pid)
end
status = $?
# close write ends so we could read them
wout.close
werr.close
stdout = rout.readlines
stderr = rerr.readlines
# dispose the read ends of the pipes
rout.close
rerr.close
rc = status.exitstatus
success = stdout.grep(/Success/).size == 3
if success
puts "#{ver}/#{env} success, #{pid}/#{rc}/#{success}"
else
puts stdout.join
puts stderr.join if stderr.size > 0
puts "#{ver}/#{env} failed, #{pid}/#{rc}/#{success}"
failed = true
end
end
end
2016-11-18 17:33:50 -05:00
exit(failed ? -1 : 0)
end
task :default => :appraise