Sha256: 027efc395407549affd55ed8178290a0bcb5917d0662a2a88704420565183b81

Contents?: true

Size: 691 Bytes

Versions: 3

Compression:

Stored size: 691 Bytes

Contents

module FireAndForget
  class Server
    def self.parse(command_string)
      command = Command.load(command_string)
      run(command)
    end

    def self.run(cmd)
      if Command.allowed?(cmd)
        cmd.run
      else
        raise PermissionsError, "'#{cmd.class}' is not an approved command"
      end
    end

    def self.kill(task_name, signal="TERM")
      pid = pids[task_name]
      Process.kill(signal, pid) unless pid == 0
    end

    def self.status
      @status ||= {}
    end

    def self.set_pid(task_name, pid)
      pids[task_name] = pid.to_i
    end

    def self.get_pid(task)
      pids[task.name]
    end

    def self.pids
      @pids ||= {}
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
fire_and_forget-0.3.1 lib/fire_and_forget/server.rb
fire_and_forget-0.3.0 lib/fire_and_forget/server.rb
fire_and_forget-0.2.0 lib/fire_and_forget/server.rb