Sha256: f0c3f299dab4893db6584a9761c3a539430bde69c42f9b42c160570376a28644
Contents?: true
Size: 875 Bytes
Versions: 10
Compression:
Stored size: 875 Bytes
Contents
# frozen_string_literal: true module Nonnative class Command < Nonnative::Service def start unless command_exists? @pid = command_spawn wait_start end pid end def stop if command_exists? command_kill wait_stop end pid end protected def wait_stop timeout.perform do Process.waitpid2(pid) end end private attr_reader :pid def command_kill signal = Signal.list[service.signal || 'INT'] || Signal.list['INT'] Process.kill(signal, pid) end def command_spawn spawn(service.command, %i[out err] => [service.file, 'a']) end def command_exists? return false if pid.nil? signal = Signal.list['EXIT'] Process.kill(signal, pid) true rescue Errno::ESRCH false end end end
Version data entries
10 entries across 10 versions & 1 rubygems