-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.rb
More file actions
executable file
·52 lines (42 loc) · 1.06 KB
/
main.rb
File metadata and controls
executable file
·52 lines (42 loc) · 1.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#!/usr/bin/env ruby
require 'aws-sdk'
require 'safe_yaml'
require 'digest'
require 'tmpdir'
require 'benchmark'
require 'json'
require 'httparty'
# Configuration depends on deserializing symbols.
# Worst case is that we run out of memory.
SafeYAML::OPTIONS[:deserialize_symbols] = true
require_relative 'common.rb'
require_relative 'configuration.rb'
require_relative 'runner.rb'
require_relative 'manager.rb'
config_file_path = ARGV[0]
raise "Configuration file path must be specified." if config_file_path.nil?
configuration = Configuration.new(config_file_path)
puts "Timeout is: #{configuration.worker_timeout}"
manager = Manager.new(configuration)
manager.run
int_count = 0
Signal.trap("USR1") do
int_count += 1
if int_count == 1
puts "Requesting Terminate"
manager.request_termination
elsif int_count == 2
puts "Forcing Terminate"
manager.terminate
else
Kernel.exit!
end
end
Signal.trap("USR2") do
manager.terminate_job
end
Signal.trap("HUP") do
puts "Requesting configuration update"
manager.update_configuration
end
manager.join