Module: Splash::Exiter

Constant Summary collapse

EXIT_MAP =
{

   # context execution
   :not_root => {:message => "This operation need to be run as root (use sudo or rvmsudo)", :code => 10},
   :options_incompatibility => {:message => "Options incompatibility", :code => 40},
   :service_dependence_missing => {:message => "Splash Service dependence missing", :code => 60},

   # config
   :specific_config_required => {:message => "Specific configuration required", :code => 30},
   :splash_setup_error => {:message => "Splash Setup terminated unsuccessfully", :code => 25},
   :splash_setup_success => {:message => "Splash Setup terminated successfully", :code => 0},
   :splash_sanitycheck_error => {:message => "Splash Sanitycheck terminated unsuccessfully", :code => 20},
   :splash_sanitycheck_success => {:message => "Splash Sanitycheck terminated successfully", :code => 0},
   :configuration_error => {:message => "Splash Configuration Error", :code => 50},


   # global
   :quiet_exit => {:code => 0},

   # events
   :interrupt => {:message => "Splash user operation interrupted", :code => 33},

   # request
   :not_found => {:message => "Object not found", :code => 44},
   :already_exist => {:message => "Object already exist", :code => 48},

   # daemon
   :status_ok => {:message => "Status OK", :code => 0},
   :status_ko => {:message => "Status KO", :code => 31}

}

Constants included from Constants

Constants::AUTHOR, Constants::BACKENDS_STRUCT, Constants::CONFIG_FILE, Constants::COPYRIGHT, Constants::DAEMON_LOGMON_SCHEDULING, Constants::DAEMON_PID_FILE, Constants::DAEMON_PID_PATH, Constants::DAEMON_PROCESS_NAME, Constants::DAEMON_STDERR_TRACE, Constants::DAEMON_STDOUT_TRACE, Constants::EMAIL, Constants::EXECUTION_TEMPLATE, Constants::EXECUTION_TEMPLATE_TOKENS_LIST, Constants::LICENSE, Constants::LOGGERS_STRUCT, Constants::PROMETHEUS_PUSHGATEWAY_HOST, Constants::PROMETHEUS_PUSHGATEWAY_PORT, Constants::TRACE_PATH, Constants::TRANSPORTS_STRUCT, Constants::VERSION

Instance Method Summary collapse

Methods included from Loggers

#change_logger, #get_logger

Methods included from Config

#get_config

Methods included from ConfigUtilities

#checkconfig, #setupsplash

Methods included from Helpers

#daemonize, #get_process, #group_root, #install_file, #is_root?, #make_folder, #make_link, #run_as_root, #search_file_in_gem, #user_root, #verify_file, #verify_folder, #verify_link, #verify_service

Instance Method Details

#splash_exit(options = {}) ⇒ Object



37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/splash/exiter.rb', line 37

def splash_exit(options = {})
  log = get_logger
  mess = ""
  mess = EXIT_MAP[options[:case]][:message] if EXIT_MAP[options[:case]].include? :message
  mess << " : " unless mess.empty? or not options[:more]
  mess << "#{options[:more]}" if options[:more]
  if  EXIT_MAP[options[:case]][:code] == 0 then
    log.success mess unless mess.empty?
    exit 0
  else
    log.fatal mess unless mess.empty?
    exit EXIT_MAP[options[:case]][:code]
  end
end