Sha256: ab11e6be7bc5649ea9886944f79c42b121c5fa81ecec723bce826f791f576826
Contents?: true
Size: 1.85 KB
Versions: 41
Compression:
Stored size: 1.85 KB
Contents
require_relative 'paths' require 'terminal-table' module AppletHelper include Paths private def path_to_jenkins_slave_applets "#{path_to_environment}/Applets/Slave" end def path_to_jenkins_master_applet "#{path_to_environment}/Applets/slave-agent (10.10).jnlp" end def applets_in_environment Dir["#{path_to_jenkins_slave_applets}/*.jnlp"] end public def should_start_slave File.exist?(path_to_environment) end def start_master `javaws "#{path_to_jenkins_master_applet}" 1>/dev/null` end 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 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 end
Version data entries
41 entries across 41 versions & 1 rubygems