Class: Metis::Application
- Inherits:
-
Object
- Object
- Metis::Application
- Defined in:
- lib/metis/application.rb
Instance Method Summary collapse
- #daemonize! ⇒ Object
-
#initialize(opts = {}) ⇒ Application
constructor
A new instance of Application.
- #run ⇒ Object
- #start ⇒ Object
Constructor Details
#initialize(opts = {}) ⇒ Application
Returns a new instance of Application.
2 3 4 |
# File 'lib/metis/application.rb', line 2 def initialize(opts={}) @options = opts end |
Instance Method Details
#daemonize! ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/metis/application.rb', line 28 def daemonize! raise 'Need to set a pid_file in order to daemonize!' unless @options[:pid_file] fork do Process.setsid exit if fork File.umask 0000 STDIN.reopen "/dev/null" STDOUT.reopen @options[:log_file], "a" STDERR.reopen STDOUT start end end |
#run ⇒ Object
6 7 8 9 10 11 12 |
# File 'lib/metis/application.rb', line 6 def run if @options[:daemonize] daemonize! else start end end |
#start ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/metis/application.rb', line 14 def start # write pid file File.open(@options[:pid_file], 'w') { |f| f.write(Process.pid.to_s) } if @options[:pid_file] # load context context = Metis::Context.new(@options[:config_file]) context.load # fire up server server = Metis::Server.new(context) server.start server.run end |