Module: ServiceManager
- Defined in:
- lib/mongrel_service/service_manager.rb
Defined Under Namespace
Classes: CreateError, ServiceError, ServiceNotFound, ServiceStruct
Class Method Summary
collapse
Class Method Details
.create(service_name, display_name, binary_path_name) ⇒ Object
9
10
11
12
13
14
15
16
17
18
|
# File 'lib/mongrel_service/service_manager.rb', line 9
def self.create(service_name, display_name, binary_path_name)
cmd = ['create']
cmd << quote(service_name)
cmd << "DisplayName=" << display_name.inspect
cmd << "binPath=" << binary_path_name.inspect
status, out = sc(*cmd)
raise CreateError.new(out) unless status == 0
return true
end
|
.delete(service_name) ⇒ Object
56
57
58
59
60
61
|
# File 'lib/mongrel_service/service_manager.rb', line 56
def self.delete(service_name)
status, out = sc('delete', quote(service_name))
raise ServiceError.new(out) unless status == 0
return true
end
|
.exist?(service_name) ⇒ Boolean
20
21
22
23
|
# File 'lib/mongrel_service/service_manager.rb', line 20
def self.exist?(service_name)
status, out = sc('query', quote(service_name))
out =~ /#{service_name}/i
end
|
.getdisplayname(service_name) ⇒ Object
41
42
43
44
45
46
47
|
# File 'lib/mongrel_service/service_manager.rb', line 41
def self.getdisplayname(service_name)
status, out = sc('GetDisplayName', quote(service_name))
raise ServiceNotFound.new(out) unless status == 0
out =~ /\=(.*)$/
$1.strip
end
|
.open(service_name) {|svc| ... } ⇒ Object
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
# File 'lib/mongrel_service/service_manager.rb', line 25
def self.open(service_name)
status, out = sc('qc', quote(service_name), 4096)
raise ServiceNotFound.new(out) unless status == 0
out =~ /BINARY\_PATH\_NAME.*\: (.*)$/
binary_path_name = $1.strip
out =~ /DISPLAY\_NAME.*\: (.*)$/
display_name = $1.strip
svc = ServiceStruct.new(service_name, display_name, binary_path_name)
yield svc if block_given?
svc
end
|
.stop(service_name) ⇒ Object
49
50
51
52
53
54
|
# File 'lib/mongrel_service/service_manager.rb', line 49
def self.stop(service_name)
status, out = net('stop', quote(service_name))
raise ServiceError.new(out) unless status == 0
return true
end
|