class Object
Public Instance Methods
main()
click to toggle source
# File exe/crota, line 9 def main Escort::App.create do |app| app.version Crota::VERSION app.description "SMPP server" app.summary <<-SUMMARY Crota is an SMPP server that will connect to any SMPP capable aggregator to send and receive messages. A list of aggregators are retrieved from Dispatch. A list of messages is then retrieved for each of these aggregators for a given number of queues. All of these values are specified in the config.yml SUMMARY app.options do |opts| opts.opt :daemonize, 'Run SMPP server in the background', short: '-d', long: '--daemonize', type: :boolean, default: false opts.opt :console, 'Open a console', short: '-k', long: '--console', type: :boolean, default: false opts.opt :verbosity, 'Verbosity level of output (DEBUG, INFO, WARN, ERROR, FATAL)', short: '-v', long: '--verbose', type: :string, default: 'INFO' opts.opt :log, 'Set default log file', short: '-l', long: '--log', type: :string, default: 'STDOUT' opts.opt :config, 'Pass your own config.yml. Must follow the same convention as detailed in repo', short: '-c', long: '--config', type: :string, default: Crota::DEFAULT_CONFIG_FILE end app.action do |options, arguments| run_crota options, arguments end end end
reload!()
click to toggle source
# File exe/crota, line 88 def reload! warn_level = $VERBOSE $VERBOSE = nil lib_dir = File.expand_path(File.join(File.dirname(__FILE__), "../lib")) files = Dir[File.join(lib_dir, "/**/*.rb")] files.each { |f| load f } $VERBOSE = warn_level "reloaded #{files.count} files" end
run_crota(options, arguments)
click to toggle source
# File exe/crota, line 40 def run_crota options, arguments opts = options[:global][:options] logger = Logger.new(opts[:log] == 'STDOUT' ? STDOUT : opts[:log]) logger.level = opts[:verbosity].downcase.to_sym Smpp::Base.logger = logger Crota.config_file = opts[:config] Crota.config.validate! server = Crota::Server.new puts "Welcome to Crota's Realm. Your light is mine." if opts[:console] start_console logger elsif opts[:daemonize] fork do logger.info("Running in BACKGROUND. You have entered Crota's realm. Beware the blight") server.start end else logger.info("Running in FOREGROUND. You have entered Crota's realm. Beware the blight") server.start end end
start_console(logger)
click to toggle source
# File exe/crota, line 66 def start_console logger require 'irb' require 'irb/completion' require 'irb/ext/save-history' lib_dir = File.expand_path(File.join(File.dirname(__FILE__), "../lib")) files = Dir[File.join(lib_dir, "/**/*.rb")] files.each { |f| require f } irbrc = File.join(ENV['HOME'], '.irbrc') unless File.exists?(irbrc) File.open(irbrc, 'w') do |f| f.write("IRB.conf[:SAVE_HISTORY] = 100\r\n") end end ARGV.clear ARGV.concat [ "--readline", "--prompt-mode", "simple" ] logger.info("Starting Crota in console mode") IRB.start end