Sha256: 08ecd2f1dcaece8c8967c317e804fd3cdb4a0948ae3227810d9da1adf8a3e8f6

Contents?: true

Size: 1.14 KB

Versions: 6

Compression:

Stored size: 1.14 KB

Contents

#!/usr/bin/ruby 

require 'rubygems'
require 'adaptation'
require 'adaptation/mom'

DEFAULT_HOST = "127.0.0.1"
DEFAULT_PORT = "8080"

# search mom configuration file.
#   - first by specified parameter
#   - second in /etc/adaptation (*nix systems)
#   - third in the gem itself

if File.exists?(File.dirname(__FILE__) + '/../configs/mom.yml')
  file = File.dirname(__FILE__) + '/../configs/mom.yml'
end

if File.exists?('/etc/adaptation/mom.yml')
  file = '/etc/adaptation/mom.yml'
end

if %w(--file -f).include? ARGV.first
  file = ARGV[1]
end

#if %w(--environment -e).include? ARGV.first
#  environment = ARGV[1]
#end
environment = "development"

if file.nil?
  config = {"mom" => {"type" => "druby", "host" => DEFAULT_HOST, "port" => DEFAULT_PORT}}
else
  config = YAML::load(File.open(file))[environment]
end

Signal.trap("INT") { puts "Shutting down MOM server (#{config["mom"]["type"]})"; exit }

case config["mom"]["type"]
  when "druby"
    mom_uri = "druby://#{config["mom"]["host"]}:#{config["mom"]["port"]}"
    mom = Adaptation::Mom::Mom.new mom_uri
    mom.start
  #when "xmlblaster"
  else
    puts "Unknown MOM server type: #{config["mom"]["type"]}"
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
adaptation-0.0.8 bin/mom
adaptation-0.0.9 bin/mom
adaptation-0.1.0 bin/mom
adaptation-0.1.1 bin/mom
adaptation-0.1.2 bin/mom
adaptation-0.1.3 bin/mom