Sha256: 93b303623ce37b2c8b37ca404d2e0f20445ea4f70184aa15618be77e2d44f025
Contents?: true
Size: 1.52 KB
Versions: 2
Compression:
Stored size: 1.52 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}` } 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 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
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
mirage-2.0.0.alpha2 | bin/mirage |
mirage-2.0.0.alpha1 | bin/mirage |