Module: Pult::Panel::Provider::Service

Defined in:
lib/init/struct.rb,
lib/pult/panel/provider/service.rb

Constant Summary collapse

PATH =
Pult::SERVICEPATH || 's'
COMMAND =
'service'
ACTIONS =
%w{start restart stop status}

Class Method Summary collapse

Class Method Details

.mixin!(panel) ⇒ Object



8
9
10
11
12
13
14
# File 'lib/pult/panel/provider/service.rb', line 8

def self.mixin! panel
  hash = pult_hash panel

  Pult::Panel::App.config_dir! hash, Dir.pwd

  panel.merge! hash
end

.pult_hash(panel) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/pult/panel/provider/service.rb', line 16

def self.pult_hash panel
  hash = {}

  for service in services
    hash[service] = {}

    for action in ACTIONS
      hash[service][action] = "#{COMMAND} #{service} #{action}"
    end
  end

  { PATH => hash }
end

.servicesObject



30
31
32
33
34
# File 'lib/pult/panel/provider/service.rb', line 30

def self.services
  runner = Pult::Executor.run! "#{COMMAND} --status-all", Dir.pwd

  runner[:stdout].scan(/[a-z][a-z\.0-9-_]+/)
end