Class: Redcap::App
Instance Attribute Summary collapse
-
#server ⇒ Object
readonly
Returns the value of attribute server.
Class Method Summary collapse
Instance Method Summary collapse
Instance Attribute Details
#server ⇒ Object (readonly)
Returns the value of attribute server.
4 5 6 |
# File 'lib/redcap/app.rb', line 4 def server @server end |
Class Method Details
.daemonise! ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/redcap/app.rb', line 10 def self.daemonise! # Daemon won't need these $stdin.reopen '/dev/null' $stdout.reopen '/dev/null', 'w' $stderr.reopen '/dev/null', 'w' # Send to the background pid = fork if pid # This is in the context of the parent - save the pid file, then exit. File.open(instance.pid_file, 'w') { |file| file.puts pid } exit! end end |
.run ⇒ Object
6 7 8 |
# File 'lib/redcap/app.rb', line 6 def self.run instance.run end |
Instance Method Details
#die(message) ⇒ Object
45 46 47 48 49 50 |
# File 'lib/redcap/app.rb', line 45 def die() $stderr.puts logger.fatal exit 1 end |
#pid_file ⇒ Object
52 53 54 |
# File 'lib/redcap/app.rb', line 52 def pid_file @pid_file ||= '/var/tmp/redcap.pid' end |
#run ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/redcap/app.rb', line 25 def run update_procline EventMachine.epoll EventMachine.run do @server = EventMachine.start_server('127.0.0.1', 11000, Redcap::Server) do |connection| connection.logger = logger end setup_signal_handlers end end |
#stop!(signal) ⇒ Object
38 39 40 41 42 43 |
# File 'lib/redcap/app.rb', line 38 def stop!(signal) logger.info "Received #{signal} signal, stopping server." stop_listening forget_server stop end |