Class: DRCtrl::Server

Inherits:
Object
  • Object
show all
Defined in:
lib/drctrl.rb

Overview

Controller service front object class.

Instance Method Summary collapse

Constructor Details

#initialize { ... } ⇒ Server

Returns a new instance of Server.

Yields:

  • Block without parameters which will be runned before stop the service.



18
19
20
# File 'lib/drctrl.rb', line 18

def initialize &block
  @block = block
end

Instance Method Details

#restartInteger

Restart the service.

Returns:

  • (Integer)

    Process ID for new process.



36
37
38
39
40
# File 'lib/drctrl.rb', line 36

def restart
  stop
  sleep 0
  spawn 'ruby', File.expand_path($0), *($*)
end

#stopvoid

This method returns an undefined value.

Stop the service.



24
25
26
27
28
29
30
31
32
# File 'lib/drctrl.rb', line 24

def stop
  if @block
    Thread.exclusive do
      block.call
    end
  end
  DRb.primary_server = DRCtrl.server
  DRb.stop_service
end