Class: Testjour::CLI::SlaveStart
Defined Under Namespace
Classes: StopServer
Instance Attribute Summary
Attributes inherited from BaseCommand
#non_options, #options
Class Method Summary
collapse
Instance Method Summary
collapse
Methods included from Bonjour
#bonjour_serve, #bonjour_servers, #found_bonjour_server
Methods inherited from BaseCommand
detailed_help, help, inherited, #option_parser, options
Constructor Details
#initialize(*args) ⇒ SlaveStart
Returns a new instance of SlaveStart.
22
23
24
25
|
# File 'lib/testjour/commands/slave_start.rb', line 22
def initialize(*args)
Testjour.logger.debug "Runner command #{self.class}..."
super
end
|
Class Method Details
.command ⇒ Object
18
19
20
|
# File 'lib/testjour/commands/slave_start.rb', line 18
def self.command
"slave:start"
end
|
Instance Method Details
#daemonize ⇒ Object
37
38
39
40
41
42
43
44
45
46
47
48
49
50
|
# File 'lib/testjour/commands/slave_start.rb', line 37
def daemonize
original_working_directory = File.expand_path(".")
pid_file = PidFile.new("./testjour_slave.pid")
pid_file.verify_doesnt_exist
at_exit { pid_file.remove }
register_signal_handler
logfile = File.expand_path("./testjour.log")
Daemonize.daemonize(logfile)
Dir.chdir(original_working_directory)
pid_file.write
end
|
#register_signal_handler ⇒ Object
58
59
60
61
62
63
|
# File 'lib/testjour/commands/slave_start.rb', line 58
def register_signal_handler
trap("TERM") do
Testjour.logger.info "TERM signal received."
raise StopServer.new
end
end
|
#run ⇒ Object
27
28
29
30
31
32
33
34
35
|
# File 'lib/testjour/commands/slave_start.rb', line 27
def run
verify_not_a_git_repo
daemonize
Testjour.setup_logger
bonjour_serve(Testjour::SlaveServer.start)
DRb.thread.join
rescue StopServer
exit 0
end
|
#verify_not_a_git_repo ⇒ Object
52
53
54
55
56
|
# File 'lib/testjour/commands/slave_start.rb', line 52
def verify_not_a_git_repo
return unless File.exists?("./.git")
puts "!!! This directory looks like a git repository. This probably isn't where you want to start a testjour slave"
exit 1
end
|