Module: RubySupervisor::GlobalAPI

Included in:
Client
Defined in:
lib/ruby-supervisor/api/global.rb

Constant Summary collapse

STATE_TO_STR =

returned by get_state

{
   2 => :fatal,
   1 => :running,
   0 => :restarting,
  -1 => :shutdown
}.freeze

Instance Method Summary collapse

Instance Method Details

#api_versionString

Return the API Version.

Returns:

  • (String)

    API Version



23
24
25
# File 'lib/ruby-supervisor/api/global.rb', line 23

def api_version
  request('getAPIVersion')
end

#clear_logObject

Clear the supervisor logs.



118
119
120
# File 'lib/ruby-supervisor/api/global.rb', line 118

def clear_log
  request('clearLog')
end

#clear_processes_logsObject

Clear logs for all processes.



99
100
101
# File 'lib/ruby-supervisor/api/global.rb', line 99

def clear_processes_logs
  request('clearAllProcessesLogs')
end

#identificationString Also known as: identifier

Return supervisor identifying string. Aliased as identifier.

Returns:

  • (String)

    identifier



42
43
44
# File 'lib/ruby-supervisor/api/global.rb', line 42

def identification
  request('getIdentification')
end

#pidInteger

Return supervisor pid.

Returns:

  • (Integer)

    PID



52
53
54
# File 'lib/ruby-supervisor/api/global.rb', line 52

def pid
  request('getPID')
end

#processesArray

Return informations for all defined processes.

Returns:

  • (Array)

    An array of hash



72
73
74
# File 'lib/ruby-supervisor/api/global.rb', line 72

def processes
  request('getAllProcessInfo')
end

#read_log(offset, length) ⇒ String

Read a chunk of the supervisor logs.

Parameters:

  • offset (Integer)

    where to start

  • length (Integer)

    How many bytes to read

Returns:

  • (String)

    logs data



111
112
113
# File 'lib/ruby-supervisor/api/global.rb', line 111

def read_log(offset, length)
  request('readLog', offset, length)
end

#restartObject

Restart the supervisor process.



125
126
127
# File 'lib/ruby-supervisor/api/global.rb', line 125

def restart
  request('restart')
end

#send_remote_comm_event(type, data) ⇒ Object

Send an event that will be received by event listener subprocesses subscribing to the RemoteCommunicationEvent



140
141
142
# File 'lib/ruby-supervisor/api/global.rb', line 140

def send_remote_comm_event(type, data)
  request('sendRemoteCommEvent', type, data)
end

#shutdownObject

Shutdown the supervisor process.



132
133
134
# File 'lib/ruby-supervisor/api/global.rb', line 132

def shutdown
  request('shutdown')
end

#start_processes(wait = true) ⇒ Object

Start all processes.

Parameters:

  • wait (Boolean) (defaults to: true)

    if true the call will block until all processes are started.



82
83
84
# File 'lib/ruby-supervisor/api/global.rb', line 82

def start_processes(wait = true)
  request('startAllProcesses', wait)
end

#stateSymbol

Return supervisor current state.

Returns:

  • (Symbol)

    Supervisor state



61
62
63
64
# File 'lib/ruby-supervisor/api/global.rb', line 61

def state
  ret = request('getState')
  STATE_TO_STR[ ret['statecode'] ]
end

#stop_processes(wait = true) ⇒ Object

Stop all processes.

Parameters:

  • wait (Boolean) (defaults to: true)

    if true the call will block until all processes are stopped.



92
93
94
# File 'lib/ruby-supervisor/api/global.rb', line 92

def stop_processes(wait = true)
  request('stopAllProcesses', wait)
end

#versionString

Return supervisor version.

Returns:

  • (String)

    Supervisor version



32
33
34
# File 'lib/ruby-supervisor/api/global.rb', line 32

def version
  request('getSupervisorVersion')
end