Initializes application components without starting the master process
# File lib/raemon/server.rb, line 7 def boot! load_environment load_lib # Must be second so that initializers have access to lib load_initializers end
@return [Pathname] the target PID file
# File lib/raemon/server.rb, line 26 def pid_file config.root.join("tmp/pids/#{server_name_key}.pid") end
Stop the master daemon
# File lib/raemon/server.rb, line 21 def shutdown! stop_master_daemon end
Start the master daemon. Exits the script if the master daemon is already running.
# File lib/raemon/server.rb, line 15 def startup! stop_if_running! start_master_daemon end
# File lib/raemon/server.rb, line 78 def config Raemon::Configuration end
# File lib/raemon/server.rb, line 62 def load_environment environment_file = config.root.join("config/environments/#{config.env}.rb") eval File.read(environment_file), binding end
# File lib/raemon/server.rb, line 82 def load_folder(path) Dir["#{path}/*.rb"].each { |file| require(file) } end
# File lib/raemon/server.rb, line 67 def load_initializers load_folder(config.root.join("config/initializers")) end
# File lib/raemon/server.rb, line 71 def load_lib libdir = config.root.join("lib") $LOAD_PATH.unshift libdir load_folder libdir end
# File lib/raemon/server.rb, line 32 def running? pid = File.read(pid_file).to_i rescue 0 Process.kill(0, pid) if pid > 0 rescue Errno::ESRCH end
# File lib/raemon/server.rb, line 86 def server_name_key config.server_name.downcase.gsub(' ', '_') end
# File lib/raemon/server.rb, line 45 def start_master_daemon config.logger.info "=> Booting #{config.server_name} (#{config.env})" Raemon::Master.start(config.num_workers, worker_class, { :name => config.server_name, :pid_file => pid_file, :detach => config.detach, :logger => config.logger, :timeout => config.timeout, :memory_limit => config.memory_limit }) end
# File lib/raemon/server.rb, line 38 def stop_if_running! if running? config.logger.error "Error: #{config.server_name} is already running." exit end end
# File lib/raemon/server.rb, line 58 def stop_master_daemon Raemon::Master.stop(:pid_file => pid_file) end
# File lib/raemon/server.rb, line 90 def worker_class instance_eval(config.worker_class) end