Module: Anyt::Command
- Defined in:
- lib/anyt/command.rb
Overview
Runs system command (websocket server)
Class Attribute Summary collapse
-
.running ⇒ Object
Returns the value of attribute running.
Class Method Summary collapse
-
.run ⇒ Object
rubocop: disable Metrics/MethodLength rubocop: disable Metrics/AbcSize.
- .running? ⇒ Boolean
-
.stop ⇒ Object
rubocop: enable Metrics/MethodLength rubocop: enable Metrics/AbcSize.
Class Attribute Details
.running ⇒ Object
Returns the value of attribute running.
7 8 9 |
# File 'lib/anyt/command.rb', line 7 def running @running end |
Class Method Details
.run ⇒ Object
rubocop: disable Metrics/MethodLength rubocop: disable Metrics/AbcSize
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/anyt/command.rb', line 11 def run return if @running AnyCable.logger.debug "Running command: #{Anyt.config.command}" out = AnyCable.config.debug ? STDOUT : IO::NULL @pid = Process.spawn( Anyt.config.command, out: out, err: out ) Process.detach(@pid) AnyCable.logger.debug "Command PID: #{@pid}" @running = true sleep Anyt.config.wait_command end |
.running? ⇒ Boolean
45 46 47 |
# File 'lib/anyt/command.rb', line 45 def running? @running == true end |
.stop ⇒ Object
rubocop: enable Metrics/MethodLength rubocop: enable Metrics/AbcSize
35 36 37 38 39 40 41 42 43 |
# File 'lib/anyt/command.rb', line 35 def stop return unless @running AnyCable.logger.debug "Terminate PID: #{@pid}" Process.kill("SIGKILL", @pid) @running = false end |