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
12
13
14
15
|
# File 'lib/linux_admin/service/systemd_service.rb', line 12
def disable
Common.run!(command_path, :params => ["disable", name])
self
end
|
#enable ⇒ Object
7
8
9
10
|
# File 'lib/linux_admin/service/systemd_service.rb', line 7
def enable
Common.run!(command_path, :params => ["enable", name])
self
end
|
#reload ⇒ Object
39
40
41
42
|
# File 'lib/linux_admin/service/systemd_service.rb', line 39
def reload
Common.run!(command_path, :params => ["reload", name])
self
end
|
#restart ⇒ Object
27
28
29
30
31
32
33
34
35
36
37
|
# File 'lib/linux_admin/service/systemd_service.rb', line 27
def restart
status = Common.run(command_path, :params => ["restart", name]).exit_status
if status != 0
stop
start
end
self
end
|
#running? ⇒ Boolean
3
4
5
|
# File 'lib/linux_admin/service/systemd_service.rb', line 3
def running?
Common.run(command_path, :params => ["status", name]).success?
end
|
#show ⇒ Object
48
49
50
51
52
53
54
|
# File 'lib/linux_admin/service/systemd_service.rb', line 48
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 ⇒ Object
17
18
19
20
|
# File 'lib/linux_admin/service/systemd_service.rb', line 17
def start
Common.run!(command_path, :params => ["start", name])
self
end
|
#status ⇒ Object
44
45
46
|
# File 'lib/linux_admin/service/systemd_service.rb', line 44
def status
Common.run(command_path, :params => ["status", name]).output
end
|
#stop ⇒ Object
22
23
24
25
|
# File 'lib/linux_admin/service/systemd_service.rb', line 22
def stop
Common.run!(command_path, :params => ["stop", name])
self
end
|