Sha256: da02a25301aa0d0d9c53092185aaa5249b6e8617d67b86f0d120f1d067c514a1
Contents?: true
Size: 1.1 KB
Versions: 5
Compression:
Stored size: 1.1 KB
Contents
module SrvManager class Service attr_reader :name attr_reader :command attr_reader :processes attr_reader :auto 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 def start processes.each(&:start) LOGGER.info "Started service #{name}" end def stop processes.each(&:stop) LOGGER.info "Stoped service #{name}" end def restart processes.each(&:restart) end def started? processes.map(&:started?).reduce(:|) end def to_hash {name: name, command: command.to_hash, processes: processes.count, auto: auto} end def self.parse(json) new json['name'], json['command']['text'], dir: json['command']['dir'], env: json['command']['env'], rvm: json['command']['rvm'], processes: json['processes'], auto: json['auto'] end end end
Version data entries
5 entries across 5 versions & 1 rubygems