Module: Rex::Service

Includes:
Ref
Included in:
Rex::Services::LocalRelay
Defined in:
lib/rex/service.rb

Overview

The service module is used to extend classes that are passed into the service manager start routine. It provides extra methods, such as reference counting, that are used to track the service instances more uniformly.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Ref

#ref, #refinit

Instance Attribute Details

#aliasObject

Returns the value of attribute alias.



45
46
47
# File 'lib/rex/service.rb', line 45

def alias
  @alias
end

Class Method Details

.hardcore_alias(*args) ⇒ Object

Returns the hardcore, as in porno, alias for this service. This is used by the service manager to manage singleton services.



23
24
25
# File 'lib/rex/service.rb', line 23

def self.hardcore_alias(*args)
  return "__#{args}"
end

Instance Method Details

#cleanupObject

Calls stop on the service once the ref count drops.



41
42
43
# File 'lib/rex/service.rb', line 41

def cleanup
  stop
end

#derefObject



27
28
29
30
31
32
33
34
35
36
# File 'lib/rex/service.rb', line 27

def deref
  rv = super

  # If there's only one reference, then it's the service managers.
  if @_references == 1
    Rex::ServiceManager.stop_service(self)
  end

  rv
end