Class: LinuxAdmin::SystemdService
- Inherits:
-
Service
- Object
- Service
- LinuxAdmin::SystemdService
show all
- Defined in:
- lib/linux_admin/service/systemd_service.rb
Instance Attribute Summary
Attributes inherited from Service
#name
Instance Method Summary
collapse
Methods inherited from Service
#initialize, new, service_type
Methods included from Logging
#logger
Instance Method Details
#disable ⇒ Object
14
15
16
17
|
# File 'lib/linux_admin/service/systemd_service.rb', line 14
def disable
Common.run!(command_path, :params => ["disable", name])
self
end
|
#enable ⇒ Object
9
10
11
12
|
# File 'lib/linux_admin/service/systemd_service.rb', line 9
def enable
Common.run!(command_path, :params => ["enable", name])
self
end
|
#reload ⇒ Object
45
46
47
48
|
# File 'lib/linux_admin/service/systemd_service.rb', line 45
def reload
Common.run!(command_path, :params => ["reload", name])
self
end
|
#restart ⇒ Object
33
34
35
36
37
38
39
40
41
42
43
|
# File 'lib/linux_admin/service/systemd_service.rb', line 33
def restart
status = Common.run(command_path, :params => ["restart", name]).exit_status
if status != 0
stop
start
end
self
end
|
#running? ⇒ Boolean
5
6
7
|
# File 'lib/linux_admin/service/systemd_service.rb', line 5
def running?
Common.run(command_path, :params => ["status", name]).success?
end
|
#show ⇒ Object
54
55
56
57
58
59
60
|
# File 'lib/linux_admin/service/systemd_service.rb', line 54
def show
output = Common.run!(command_path, :params => ["show", name]).output
output.split("\n").each_with_object({}) do |line, h|
k, v = line.split("=", 2)
h[k] = cast_show_value(k, v)
end
end
|
#start(enable = false) ⇒ Object
19
20
21
22
23
24
25
26
|
# File 'lib/linux_admin/service/systemd_service.rb', line 19
def start(enable = false)
if enable
Common.run!(command_path, :params => ["enable", "--now", name])
else
Common.run!(command_path, :params => ["start", name])
end
self
end
|
#status ⇒ Object
50
51
52
|
# File 'lib/linux_admin/service/systemd_service.rb', line 50
def status
Common.run(command_path, :params => ["status", name]).output
end
|
#stop ⇒ Object
28
29
30
31
|
# File 'lib/linux_admin/service/systemd_service.rb', line 28
def stop
Common.run!(command_path, :params => ["stop", name])
self
end
|