class SrvManager::Service

Attributes

auto[R]
command[R]
name[R]
processes[R]

Public Class Methods

new(name, command, options={}) click to toggle source
# File lib/srv_manager/service.rb, line 9
def initialize(name, command, options={})
  @name = name
  
  @command = Command.new command, options
  
  @processes = (options[:processes] || 1).times.map do 
    Process.new @command
  end

  @auto = options[:auto] || false
end
parse(json) click to toggle source
# File lib/srv_manager/service.rb, line 48
def self.parse(json)
  new json['name'], 
      json['command']['text'], 
      dir: json['command']['dir'], 
      env: json['command']['env'], 
      rvm: json['command']['rvm'], 
      pidfile: json['command']['pidfile'], 
      processes: json['processes'],
      auto: json['auto']
end

Public Instance Methods

kill() click to toggle source
# File lib/srv_manager/service.rb, line 31
def kill
  processes.each(&:kill)
  LOGGER.info "Killed service #{name}"
end
restart() click to toggle source
# File lib/srv_manager/service.rb, line 36
def restart
  processes.each(&:restart)
end
start() click to toggle source
# File lib/srv_manager/service.rb, line 21
def start
  processes.each(&:start)
  LOGGER.info "Started service #{name}"
end
started?() click to toggle source
# File lib/srv_manager/service.rb, line 40
def started?
  processes.map(&:started?).reduce(:|)
end
stop() click to toggle source
# File lib/srv_manager/service.rb, line 26
def stop
  processes.each(&:stop)
  LOGGER.info "Stoped service #{name}"
end
to_hash() click to toggle source
# File lib/srv_manager/service.rb, line 44
def to_hash
  {name: name, command: command.to_hash, processes: processes.count, auto: auto}
end