Module: AppletHelper
Instance Method Summary
collapse
Methods included from Paths
#path_to_backup, #path_to_environment, #path_to_provisioning_updater, #root_jenkins_path
Instance Method Details
#should_start_slave ⇒ Object
21
22
23
|
# File 'lib/nixenvironment/jenkins/Modules/applet_helper.rb', line 21
def should_start_slave
File.exist?(path_to_environment)
end
|
#start_master ⇒ Object
25
26
27
|
# File 'lib/nixenvironment/jenkins/Modules/applet_helper.rb', line 25
def start_master
`javaws "#{path_to_jenkins_master_applet}" 1>/dev/null`
end
|
#start_slave ⇒ Object
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
# File 'lib/nixenvironment/jenkins/Modules/applet_helper.rb', line 29
def start_slave
applets = applets_in_environment
rows = []
applets.each_with_index do |applet_file, index|
file_name = File.basename(applet_file, ".jnlp")
rows << [index, file_name]
end
table = Terminal::Table.new :headings => ['Index', 'Slave name'], :rows => rows
puts(table)
while true
print('Enter index > ')
user_input = STDIN.gets.to_i
if (0...applets.count).include?(user_input)
`javaws "#{applets[user_input]}" 1>/dev/null`
break
end
end
end
|
#stop_applets ⇒ Object
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
|
# File 'lib/nixenvironment/jenkins/Modules/applet_helper.rb', line 53
def stop_applets
begin
java_processes = `jps -v`
applets = applets_in_environment
applets << path_to_jenkins_master_applet
applets.each do |file_path|
java_processes.each_line do |line|
if line.include? file_path
pid = line.split.first
`kill -9 #{pid}`
puts("Process #{pid} stoped")
end
end
end
puts("Stop applets: done")
rescue
puts("Stop applets: fail")
end
end
|