Sha256: 8f807e44eaaa86db73ca6560e245323b8cab992e8273c5be6d202af9fb04d6e5
Contents?: true
Size: 1.65 KB
Versions: 11
Compression:
Stored size: 1.65 KB
Contents
#!/usr/bin/env ruby require 'rubygems' require 'childprocess' ROOT_DIR = File.dirname(__FILE__) $LOAD_PATH.unshift("#{ROOT_DIR}/../lib") $LOAD_PATH.unshift("#{ROOT_DIR}/../server") require 'mirage/client' require 'waitforit' require 'util' include Mirage::Util RUBY_CMD = RUBY_PLATFORM == 'java' ? 'jruby' : 'ruby' def start_mirage(args) puts "Starting Mirage" if windows? command = ["cmd", "/C", "start", "\"mirage server\"", RUBY_CMD, "#{File.dirname(__FILE__)}/../mirage_server.rb"] else command = [RUBY_CMD, "#{File.dirname(__FILE__)}/../mirage_server.rb"] end ChildProcess.build(*(command.concat(args))).start Mirage::Client.new "http://localhost:#{parse_options(ARGV)[:port]}/mirage" end def mirage_process_ids if windows? [`tasklist /V | findstr "mirage\\ server"`.split(' ')[1]].compact else ["Mirage Server", 'mirage_server'].collect do |process_name| `ps aux | grep "#{process_name}" | grep -v grep`.split(' ')[1] end.find_all { |process_id| process_id != $$.to_s }.compact end end def stop_mirage mirage_process_ids.each { |process_id| windows? ? `taskkill /F /T /PID #{process_id}` : `kill -9 #{process_id}` } wait_until{ mirage_process_ids.size == 0 } end if ARGV.include?('start') unless mirage_process_ids.empty? puts "Mirage is already running" exit 1 end mirage_client = start_mirage(ARGV) wait_until :timeout_after => 30.seconds do mirage_client.running? end begin mirage_client.prime rescue Mirage::InternalServerException => e puts "WARN: #{e.message}" end elsif ARGV.include?('stop') puts "Stopping Mirage" stop_mirage else parse_options ['--help'] exit 1 end
Version data entries
11 entries across 11 versions & 1 rubygems