Sha256: 774082ed0daa2e9669a95c9592895a231c98631a129698ab024d245f21842cc2
Contents?: true
Size: 1.85 KB
Versions: 35
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/master-agent.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
35 entries across 35 versions & 1 rubygems