module Anycablebility::Command

Runs system command (websocket server)

Attributes

running[RW]

Public Class Methods

run() click to toggle source

rubocop: disable Metrics/MethodLength

# File lib/anycablebility/command.rb, line 10
def run
  return if @running

  Anycable.logger.debug "Running command: #{Anycablebility.config.command}"

  out = Anycable.config.debug ? STDOUT : IO::NULL

  @pid = Process.spawn(
    Anycablebility.config.command,
    out: out,
    err: out
  )

  Process.detach(@pid)

  Anycable.logger.debug "Command PID: #{@pid}"

  @running = true

  sleep Anycablebility.config.wait_command
end
running?() click to toggle source
# File lib/anycablebility/command.rb, line 43
def running?
  @running == true
end
stop() click to toggle source

rubocop: enable Metrics/MethodLength

# File lib/anycablebility/command.rb, line 33
def stop
  return unless @running

  Anycable.logger.debug "Terminate PID: #{@pid}"

  Process.kill("SIGKILL", @pid)

  @running = false
end