lib/linux_admin/service.rb in linux_admin-0.1.1 vs lib/linux_admin/service.rb in linux_admin-0.1.2

- old
+ new

@@ -18,23 +18,42 @@ 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"] }, + :return_exitstatus => true) + + # attempt to manually stop/start if restart fails + if status != 0 + self.stop + self.start + end + + self end end end