require 'rubygems' require "pp" require File.join(File.dirname(__FILE__),'exception.rb') begin require 'sinatra/base' require "logger" require "thin" require 'activesupport' unless ({}.respond_to? :to_json) rescue LoadError => e p < #{vars[:logger]}" unless vars[:logger] case vars[:mode].to_sym when :PULL vars[:logger].debug "Entry PULL mode" require File.join(File.dirname(__FILE__),'pull','lpmp.rb') LPMPServer.run!('0.0.0.0',vars[:port]||6789) when :BGPULL # not complete. # require File.join(File.dirname(__FILE__),'bg_pull','lpmp.rb') when :XQPUSH vars[:logger].debug "Entry XQPUSH mode" require File.join(File.dirname(__FILE__),'xq_push','lpmp.rb') require File.join(File.dirname(__FILE__),'xq_push','caichen.rb') begin LPMPServer.run(Lpmp::Caichen.new(vars),:port => vars[:port]||6789) rescue ParamsError => e vars[:logger].fatal "XQPUSH mode start failed.Maybe Lpmp::Caichen.new(#{vars.inspect}) error.#{$/}#{e.to_s}." raise e rescue Exception => e p "LPMP start error!" p e.to_s end else vars[:logger].error "No mode fit.vars[:mode] => #{vars[:mode]}.#{$/}Only one of %w[PULL BGPULL XQPUSH] is available." end end end