Class: Nodectl::Server
- Inherits:
-
Object
- Object
- Nodectl::Server
- Defined in:
- lib/nodectl/server.rb
Instance Attribute Summary collapse
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ Server
constructor
A new instance of Server.
- #run ⇒ Object
- #stop ⇒ Object
- #stop! ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Server
Returns a new instance of Server.
4 5 6 |
# File 'lib/nodectl/server.rb', line 4 def initialize( = {}) @options = self.class..merge() end |
Instance Attribute Details
#options ⇒ Object (readonly)
Returns the value of attribute options.
2 3 4 |
# File 'lib/nodectl/server.rb', line 2 def @options end |
Class Method Details
.default_options ⇒ Object
49 50 51 |
# File 'lib/nodectl/server.rb', line 49 def self. @default_options ||= YAML.load_file(Nodectl.[:config_dir].join('server.yml')) end |
Instance Method Details
#run ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/nodectl/server.rb', line 8 def run if @options["daemonize"] if Process.fork exit else Nodectl.shut_up! end end if @options["pidfile"] File.open(@options["pidfile"], "w") do |file| file.write(Process.pid) end at_exit { File.unlink @options["pidfile"] } end Nodectl.logger.info "server with pid #{Process.pid} started" at_exit { Nodectl.logger.info "server with pid #{Process.pid} shutting down" } Nodectl::Service.load_register Nodectl::Instance.load_register EM.run do setup_signals rack_run watchdog_run stream_run end end |
#stop ⇒ Object
39 40 41 42 |
# File 'lib/nodectl/server.rb', line 39 def stop @thin.stop if @thin EM.stop end |
#stop! ⇒ Object
44 45 46 47 |
# File 'lib/nodectl/server.rb', line 44 def stop! @thin.stop! if @thin EM.stop end |