Sha256: 700e2ee29b5c44e15624d0676442e370a849cc187708be30ef1b0eb64df7c149

Contents?: true

Size: 757 Bytes

Versions: 15

Compression:

Stored size: 757 Bytes

Contents

# encoding: utf-8
module LocalPac
  module Actions
    class SendSignal
      private

      attr_reader :signal, :pid_file, :signalizer

      public

      def initialize(signal, pid_file = LocalPac.config.pid_file, signalizer = Process)
        @signal     = signal
        @pid_file   = pid_file
        @signalizer = signalizer
      end

      def run
        signalizer.kill signal, pid
      rescue Exceptions::PidFileDoesNotExist
        LocalPac.ui_logger.error "Pid-file \"#{pid_file}\" does not exist. I'm not able to send daemon signal \"#{signal}\"."
      end

      private

      def pid
        ::File.read(pid_file).to_i
      rescue Errno::ENOENT => e
        raise Exceptions::PidFileDoesNotExist, e.message
      end
    end
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
local_pac-0.10.2 lib/local_pac/actions/send_signal.rb
local_pac-0.10.1 lib/local_pac/actions/send_signal.rb
local_pac-0.10.0 lib/local_pac/actions/send_signal.rb
local_pac-0.9.0 lib/local_pac/actions/send_signal.rb
local_pac-0.7.0 lib/local_pac/actions/send_signal.rb
local_pac-0.6.3 lib/local_pac/actions/send_signal.rb
local_pac-0.6.2 lib/local_pac/actions/send_signal.rb
local_pac-0.6.1 lib/local_pac/actions/send_signal.rb
local_pac-0.5.0 lib/local_pac/actions/send_signal.rb
local_pac-0.4.0 lib/local_pac/actions/send_signal.rb
local_pac-0.3.0 lib/local_pac/actions/send_signal.rb
local_pac-0.2.3 lib/local_pac/actions/send_signal.rb
local_pac-0.2.2 lib/local_pac/actions/send_signal.rb
local_pac-0.2.1 lib/local_pac/actions/send_signal.rb
local_pac-0.2.0 lib/local_pac/actions/send_signal.rb