Module: ServerStarter
- Extended by:
- ServerStarter
- Includes:
- Librr::Logger::ClassLogger
- Included in:
- ServerStarter
- Defined in:
- lib/librr/server_starter.rb
Instance Method Summary collapse
Methods included from Librr::Logger::ClassLogger
Instance Method Details
#run ⇒ Object
12 13 14 15 16 17 |
# File 'lib/librr/server_starter.rb', line 12 def run require 'librr' require 'librr/runner' Librr::Runner.new.run! end |
#start_server(sync) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/librr/server_starter.rb', line 19 def start_server(sync) puts 'daemon starting..' if sync Librr::Logger.instance.logger.level = Logger::DEBUG return self.run end Process.fork do sess_id = Process.setsid Process.fork do redirect_std do # for daemon, logger all information to log file logger = Logger.new(Settings.in_dir('daemon.log'), 10, 1024000) logger.level = Logger::DEBUG Librr::Logger.instance.logger = logger self.debug "daemon started." self.run end exit end exit end end |
#wait_for_server_started(&block) ⇒ Object
43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/librr/server_starter.rb', line 43 def wait_for_server_started &block 5.times.each do sleep(2) puts 'waiting for daemon starting..' if File.exists?(Settings::PID_FILE) return block.call if block end end puts "daemon not starting, something is wrong." exit end |