Sha256: ec23ac823612eebb55253db48f3b136178d4e0d7fd3c41a2e703603c81830001
Contents?: true
Size: 1.47 KB
Versions: 3
Compression:
Stored size: 1.47 KB
Contents
#!/usr/bin/env ruby require 'rubygems' $LOAD_PATH.unshift("#{File.dirname(__FILE__)}/../lib") require 'mirage' require 'childprocess' 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__)}/../lib/start_mirage.rb"] else command = [RUBY_CMD, "#{File.dirname(__FILE__)}/../lib/start_mirage.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", 'start_mirage'].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}` } 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 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
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
mirage-1.3.6 | bin/mirage |
mirage-1.3.5 | bin/mirage |
mirage-1.3.4 | bin/mirage |