win32_service_manager 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/win32_service_manager.rb +8 -5
- data/tasks/git.rake +1 -1
- metadata +1 -1
@@ -2,21 +2,19 @@ require 'win32_service_manager/core_ext/struct_to_hash'
|
|
2
2
|
|
3
3
|
class Win32ServiceManager
|
4
4
|
|
5
|
-
VERSION = '0.1.
|
5
|
+
VERSION = '0.1.1'
|
6
6
|
def self.version; VERSION; end
|
7
7
|
def self.load_dependencies; require 'win32/service'; end
|
8
8
|
|
9
9
|
# Construct a new service manager, just sets up a name_key, which is used
|
10
10
|
# as a leading string to the name of all services managed by the instance.
|
11
|
-
# srv_any_path must be a full path to srvany.exe.
|
12
11
|
def initialize(name_key = '')
|
13
12
|
self.class.load_dependencies
|
14
13
|
@name_key = name_key
|
15
14
|
end
|
16
15
|
|
17
16
|
# Create a new service. The service name will be appended to the name_key
|
18
|
-
# and inserted into the registry using Win32::Service.
|
19
|
-
# then adjusted with win32-registry.
|
17
|
+
# and inserted into the registry using Win32::Service.
|
20
18
|
# One recommended pattern is to store persisence details about the service
|
21
19
|
# as yaml in the optional description field.
|
22
20
|
def create(name, command, args = '', description = nil, options = {})
|
@@ -40,21 +38,26 @@ class Win32ServiceManager
|
|
40
38
|
Win32::Service.delete(n(name))
|
41
39
|
end
|
42
40
|
|
41
|
+
# Schedule the service for start
|
43
42
|
def start(name)
|
44
43
|
Win32::Service.start(n(name))
|
45
44
|
end
|
46
45
|
|
46
|
+
# Schedule the service for stop
|
47
47
|
def stop(name)
|
48
48
|
Win32::Service.stop(n(name))
|
49
49
|
end
|
50
50
|
|
51
|
-
# Returns an array of
|
51
|
+
# Returns an array of hashes derived from the Win32::Service::SvcInfo struct
|
52
|
+
# The optional argument will cut the array down to a single element for a
|
53
|
+
# service with the given name.
|
52
54
|
def status(name = nil)
|
53
55
|
list = name ? services.select { |s| s.display_name == name } : services
|
54
56
|
list.map { |svc_info| svc_info.to_hash }
|
55
57
|
end
|
56
58
|
alias_method :list, :status
|
57
59
|
|
60
|
+
# List all services that have names which start with the name_key.
|
58
61
|
def services
|
59
62
|
Win32::Service.services.select do |svc|
|
60
63
|
# TODO in future, 1.8.7, can use start_with?
|
data/tasks/git.rake
CHANGED