Class: Bixby::Provision::Service

Inherits:
Base
  • Object
show all
Defined in:
lib/bixby/provision/dsl/service.rb

Constant Summary

Constants inherited from Base

Base::PATH

Instance Attribute Summary

Attributes inherited from Base

#manifest, #proxy

Instance Method Summary collapse

Methods inherited from Base

#get_gid, #get_group, #get_uid, #get_user, #tap, #tempfile

Methods included from Util::File

#chmod, #chown, #sha256sum, #which

Constructor Details

#initialize(*args) ⇒ Service

Returns a new instance of Service.



10
11
12
13
14
15
16
17
# File 'lib/bixby/provision/dsl/service.rb', line 10

def initialize(*args)
  super
  @services = if ubuntu? then
      Services::Init.new(self)
    elsif centos? or amazon? then
      Services::Init.new(self)
    end
end

Instance Method Details

#ensure(name) ⇒ Object



43
44
45
46
47
48
49
# File 'lib/bixby/provision/dsl/service.rb', line 43

def ensure(name)
  if centos? or amazon? then
    logged_sudo("chkconfig --add #{name}")
  elsif ubuntu? then
    logged_sudo("update-rc.d #{name} defaults")
  end
end

#reload(name, opts = {}) ⇒ Object



35
36
37
# File 'lib/bixby/provision/dsl/service.rb', line 35

def reload(name, opts={})
  @services.reload(name, opts)
end

#restart(name, opts = {}) ⇒ Object



31
32
33
# File 'lib/bixby/provision/dsl/service.rb', line 31

def restart(name, opts={})
  @services.restart(name, opts)
end

#running?(name) ⇒ Boolean

Returns:

  • (Boolean)


39
40
41
# File 'lib/bixby/provision/dsl/service.rb', line 39

def running?(name)
  @services.running?(name)
end

#start(name, opts = {}) ⇒ Object



19
20
21
22
23
# File 'lib/bixby/provision/dsl/service.rb', line 19

def start(name, opts={})
  if !running?(name) || opts[:force] == true then
    @services.start(name, opts)
  end
end

#stop(name, opts = {}) ⇒ Object



25
26
27
28
29
# File 'lib/bixby/provision/dsl/service.rb', line 25

def stop(name, opts={})
  if running?(name) || opts[:force] == true then
    @services.stop(name, opts)
  end
end