Sha256: 92750c85487214e743cc6bf8eef6d39f3658ff74ff723aa3905e4e7e4abd6c6d
Contents?: true
Size: 1.05 KB
Versions: 1
Compression:
Stored size: 1.05 KB
Contents
# LinuxAdmin Service Representation # # Copyright (C) 2013 Red Hat Inc. # Licensed under the MIT License class LinuxAdmin class Service < LinuxAdmin attr_accessor :id def initialize(id) @id = id end def running? run(cmd(:service), :params => { nil => [id, "status"] }).exit_status == 0 end def enable run!(cmd(:systemctl), :params => { nil => ["enable", "#{id}.service"] }) self end def disable run!(cmd(:systemctl), :params => { nil => ["disable", "#{id}.service"] }) self end def start run!(cmd(:service), :params => { nil => [id, "start"] }) self end def stop run!(cmd(:service), :params => { nil => [id, "stop"] }) self end def restart status = run(cmd(:service), :params => { nil => [id, "restart"] }).exit_status # attempt to manually stop/start if restart fails if status != 0 self.stop self.start end self end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
linux_admin-0.2.0 | lib/linux_admin/service.rb |