Class: TorqueBox::Service

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

Overview

This class is a Ruby API to manipulating TorqueBox services (daemons).

Class Method Summary collapse

Class Method Details

.listArray<org.torquebox.services.RubyService>

List all services of this application.

Returns:

  • (Array<org.torquebox.services.RubyService>)

    the list of RubyService instances - see lookup for more details on these instances



28
29
30
31
32
33
34
35
36
37
38
# File 'lib/torquebox/service.rb', line 28

def list
  prefix = service_prefix.canonical_name
  suffix = '.create'
  service_names = TorqueBox::MSC.service_names.select do |service_name|
    name = service_name.canonical_name
    name.start_with?(prefix) && name.end_with?(suffix)
  end
  service_names.map do |service_name|
    TorqueBox::MSC.get_service(service_name).value
  end
end

.lookup(name) ⇒ org.torquebox.services.RubyService

Note:

The RubyService instances returned by this and the list methods are not instances of this class but are instead Java objects of type org.torquebox.services.RubyService. There are more methods available on these instances than what’s shown in the example here, but only the methods shown are part of our documented API.

Lookup a service of this application by name.

Examples:

Stop a running service

service = TorqueBox::Service.lookup('my_service')
service.name => 'my_service'
service.started? => true
service.status => 'STARTED'
service.stop
service.status => 'STOPPED'

Parameters:

  • name (String)

    the service’s name (as given in torquebox.rb or torquebox.yml)

Returns:

  • (org.torquebox.services.RubyService)

    The RubyService instance.



63
64
65
66
67
# File 'lib/torquebox/service.rb', line 63

def lookup(name)
  service_name = service_prefix.append(name).append('create')
  service = TorqueBox::MSC.get_service(service_name)
  service.nil? ? nil : service.value
end