Class: LinuxAdmin::SystemdService
- Inherits:
-
Service
- Object
- Service
- LinuxAdmin::SystemdService
show all
- Defined in:
- lib/linux_admin/service/systemd_service.rb
Constant Summary
Constants included
from Common
Common::BIN_DIRS
Instance Attribute Summary
Attributes inherited from Service
#name
Instance Method Summary
collapse
Methods inherited from Service
#initialize, new, service_type
Methods included from Common
#cmd, #cmd?, #run, #run!
Instance Method Details
#disable ⇒ Object
14
15
16
17
18
|
# File 'lib/linux_admin/service/systemd_service.rb', line 14
def disable
run!(cmd(:systemctl),
:params => {nil => ["disable", name]})
self
end
|
#enable ⇒ Object
8
9
10
11
12
|
# File 'lib/linux_admin/service/systemd_service.rb', line 8
def enable
run!(cmd(:systemctl),
:params => {nil => ["enable", name]})
self
end
|
#restart ⇒ Object
32
33
34
35
36
37
38
39
40
41
42
43
44
|
# File 'lib/linux_admin/service/systemd_service.rb', line 32
def restart
status =
run(cmd(:systemctl),
:params => {nil => ["restart", name]}).exit_status
if status != 0
stop
start
end
self
end
|
#running? ⇒ Boolean
3
4
5
6
|
# File 'lib/linux_admin/service/systemd_service.rb', line 3
def running?
run(cmd(:systemctl),
:params => {nil => ["status", name]}).exit_status == 0
end
|
#start ⇒ Object
20
21
22
23
24
|
# File 'lib/linux_admin/service/systemd_service.rb', line 20
def start
run!(cmd(:systemctl),
:params => {nil => ["start", name]})
self
end
|
#stop ⇒ Object
26
27
28
29
30
|
# File 'lib/linux_admin/service/systemd_service.rb', line 26
def stop
run!(cmd(:systemctl),
:params => {nil => ["stop", name]})
self
end
|