win32-service 0.7.2-x86-mingw32

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGES ADDED
@@ -0,0 +1,254 @@
1
+ == 0.7.2 - 7-Sep-2011
2
+ * Now works with mingw compiler by skipping __try and __finally if using
3
+ mingw, or using them with mingw if the seh.h header is found.
4
+ * The binary gem now contains binaries for both Ruby 1.8.7 and 1.9.2 using
5
+ a simple wrapper.
6
+ * Updated some Rake tasks.
7
+
8
+ == 0.7.1 - 9-Feb-2010
9
+ * Compatibility fixes for 1.9.x.
10
+ * Fixed a bug where the controls_accepted struct member was always nil. This
11
+ has been fixed and now always returns an array.
12
+ * Added 'pre-shutdown' as possible values for the list of controls accepted.
13
+ * Changed test-unit from a runtime dependency to a development dependency.
14
+ * Some tests were refactored to be more reliable.
15
+ * Refactored the Rakefile and gemspec.
16
+
17
+ == 0.7.0 - 30-Jun-2009
18
+ * INTERFACE CHANGE: The Service.new and Service.configure methods now accept
19
+ a single hash argument only. The :service_name key is mandatory, while the
20
+ :host key is optional.
21
+ * Fixed a bug in the Service.services method where a segfault would occur if
22
+ the binary_path_name was greater than 260 characters. The buffer size has
23
+ been increased to 1024 characters. Thanks go to Dan Daniels for the spot.
24
+ * Altered the Daemon class so that the Ruby interpreter was not invoked within
25
+ the Service_Main function. The functions that close stdin, stdout and stderr
26
+ are now called within the mainloop method. Thanks go to Tim Hanson for the
27
+ spot and the patch.
28
+ * Eliminated a minor build warning in daemon.c
29
+ * License changed to Artistic 2.0, with corresponding gemspec update.
30
+ * Added an uninstall rake task.
31
+ * Updated the service_stop method in the demo_daemon.rb file, and added some
32
+ additional comments.
33
+ * The test files were renamed.
34
+ * Several tests were updated and refactored to use Test::Unit 2.x. That
35
+ library is now a dependency.
36
+ * The 'uninstall' Rakefile task is now more verbose.
37
+
38
+ == 0.6.1 - 1-Jan-2008
39
+ * The Service.services method now handles the scenario where a particular
40
+ service may still exist, but its underlying registry entry has been deleted.
41
+ In this case, most ServiceInfo struct members are set to nil and a warning
42
+ is issued.
43
+ * RDoc updates.
44
+
45
+ == 0.6.0 - 25-Nov-2007
46
+ * The Service control class is now pure Ruby. The Daemon class is still C,
47
+ however. That may change in the future. This means the windows-pr
48
+ library is now a prerequisite.
49
+ * The Service.new method has been altered in a way that is not backwards
50
+ compatible. It is now the same as Service.create.
51
+ * The Service.start method now properly handles arguments to the
52
+ Daemon#service_main method.
53
+ * The Daemon source code is now separate from the Service control class
54
+ source code. That means you must require them separately, as needed.
55
+ * The Daemon class should be much more responsive to service events now,
56
+ especially service_stop. Many thanks go to Kevin Burge for the patch.
57
+ * Added the Daemon.mainloop method as a shortcut for Daemon.new.mainloop.
58
+ * The Daemon class now redirects STDIN, STDOUT and STDERR to the NUL device
59
+ if they're still associated with a terminal when the service starts. This
60
+ should help prevent Errno::EBADF errors.
61
+ * The Service.services class method now supports the group parameter for
62
+ versions of Ruby built with older compilers, i.e. it will now work with
63
+ the one-click Ruby installer.
64
+ * The Service.getdisplayname method was changed to Service.get_display_name.
65
+ An alias has been provided for backwards compatibility.
66
+ * The Service.getservicename method was changed to Service.get_service_name.
67
+ An alias has been provided for backwards compatibility.
68
+ * Added the Service.config_info method.
69
+ * The Service.create and Service.configure methods now allow you to set
70
+ failure actions, failure commands, and reset/retry periods.
71
+ * Improved test suite.
72
+ * Changed 'tdaemon.rb', 'tdaemon_ctl.rb' and 'service_test.rb' to
73
+ 'demo_daemon.rb', 'demo_daemon_ctl.rb' and 'demo_services.rb', respectively.
74
+ * Some refactoring and updates to the demo daemon and demo daemon controller
75
+ examples.
76
+ * The Win32Service struct is now ServiceInfo.
77
+ * ServiceError is now Service::Error.
78
+ * DaemonError is now Daemon::Error.
79
+ * Some documentation improvements, corrections and updates.
80
+
81
+ == 0.5.2 - 25-Nov-2006
82
+ * Fixed a bug in the Daemon class where the service event handling methods
83
+ (most notably service_stop) did not work properly due to thread blocking
84
+ issues. Many thanks go to Patrick Hurley for the patch.
85
+ * Added the Daemon#running? method as helper method for your service_main
86
+ method.
87
+ * The 'interactive?' struct member is now just 'interactive'. This was
88
+ supposed to have been in the last release but was somehow missed. Sorry.
89
+ * Scrapped the old daemon_test.rb file and split it into two new files -
90
+ tdaemon.rb and tdaemon_ctl.rb. In the process a few bugs were fixed.
91
+ * Added a gemspec.
92
+ * Documentation and test suite updates.
93
+
94
+ == 0.5.1 - 18-Jun-2006
95
+ * Added the Service.open method.
96
+ * The Service.new method now accepts a block, and automatically closes itself
97
+ at the end of the block.
98
+ * Fixed in a bug in the Service.create method where setting dependencies
99
+ was not working properly. Thanks go to Scott Harper for the spot.
100
+ * The 'interactive?' struct member is now just 'interactive' since Ruby no
101
+ longer supports question marks in struct member names. UGH.
102
+ * The block for Service#configure_service is no longer optional.
103
+ * Replaced ClipSrv with W32Time for most of the test methods in tc_service.rb
104
+ because it had a dependency that is disabled on most systems.
105
+ * Added a tweak to the extconf.rb file to help with the test suite.
106
+ * Some documentation updates and corrections.
107
+
108
+ == 0.5.0 - 26-Nov-2005
109
+ * Added a service_init hook, and (internally) altered the way the service
110
+ starts. This was done to deal with services that need to perform any
111
+ initialization in the Daemon itself before the service starts. Previously
112
+ this would result in the service timing out during startup.
113
+
114
+ Thanks go to Jamey Cribbs for spotting the problem.
115
+
116
+ * Modified the Daemon example, adding a service_init hook that does about 10
117
+ seconds worth of initialization before finally starting. See the comments
118
+ in examples\daemon_test.rb for more information.
119
+ * Minor test and README changes.
120
+
121
+ == 0.4.6 - 24-May-2005
122
+ * Fixed an initialization bug that could cause Daemons to fail unless the
123
+ win32-service package was the last package require'd.
124
+ * Altered the Service.start method. It now takes any number of arguments
125
+ (after the service and host name). These arguments are passed to the
126
+ service's Service_Main() function.
127
+ * The Service.services method now returns an Array of ServiceStruct's in
128
+ non-block form.
129
+ * The Service.start, Service.pause, Service.resume, Service.stop and
130
+ Service.delete methods now return the class (self), not 'true'.
131
+ * Added the ability to add or configure the service description in
132
+ Service#create_service or Service#configure, respectively.
133
+ * Fixed a bug in the Service.start method where false positives could result.
134
+ * Updated the ServiceStatus struct to include pid and service_flags on Win2k
135
+ or later.
136
+ * Unicode is now the default setting as far as internal string handling. It
137
+ will still work fine with 'regular' text.
138
+ * Added safe string handling for string input values.
139
+ * Added rdoc comments into the C source.
140
+ * Made the service.txt and daemon.txt files rdoc friendly.
141
+ * Removed the service.rd and daemon.rd files. If you want html documentation,
142
+ run rdoc over the service.txt and daemon.txt files.
143
+ * The dreaded "code cleanup".
144
+
145
+ == 0.4.5 - 28-Feb-2005
146
+ * Fixed an accessor bug in Service#create. Thanks go to Nathaniel Talbott
147
+ for the spot.
148
+ * Eliminated a warning that appeared starting in Ruby 1.8.2 regarding Struct
149
+ redefinitions.
150
+ * Moved 'examples' directory to toplevel directory.
151
+ * Deleted the 'test2.rb' example. This was supplanted by the 'daemon_test.rb'
152
+ script.
153
+ * Renamed the 'test.rb' file to 'services_test.rb'.
154
+ * Made this document rdoc friendly.
155
+
156
+ == 0.4.4 - 27-Aug-2004
157
+ * Modified the Service class to use the newer allocation framework. The
158
+ Daemon class already used this, hence no major version bump.
159
+ * Fixed in a bug in the create_service() method with regards to the
160
+ 'dependencies' option and null arguments (you no longer need to specify
161
+ an empty array).
162
+
163
+ == 0.4.3 - 14-Aug-2004
164
+ * Fixed the Daemon class by adding back the constants it needed in order to
165
+ run. I accidentally broke this when I changed the Daemon class from being
166
+ a subclass of Service to being its own class.
167
+ * Added a separate test suite for the Daemon class, tc_daemon.rb, to help
168
+ me from making that mistake ever again. :)
169
+ * Updated the daemon_test.rb script a bit to report error messages should
170
+ any occur.
171
+ * Minor doc updates
172
+
173
+ == 0.4.2 - 10-Jul-2004
174
+ * The Daemon class is no longer a subclass of Service.
175
+ * Added the 'pid' and 'service_flags' struct members to the Win32Service
176
+ struct. These members are only available to folks using Windows 2000 or
177
+ later and who compile with VC++ 7.0 or later (including the .NET SDK).
178
+ * The Service.services method now accepts a group name as an optional third
179
+ argument. Again, you must be using Windows 2000 or later and compile with
180
+ VC++ 7.0 or later (including the .NET SDK).
181
+ * The deprecated STR2CSTR() functions were replaced with StringValuePtr().
182
+ This also means that as of this version, win32-service requires Ruby
183
+ 1.8.0 or greater.
184
+ * Moved the sample programs to doc/examples
185
+ * Removed the .html files under /doc. You can generate that on your own if
186
+ you like.
187
+
188
+ == 0.4.1 - 14-Mar-2004
189
+ * Added the exists? class method and corresponding test suite additions.
190
+ * Pushed the ServiceError and DaemonError classes under the Win32 module.
191
+ * Normalized tc_service.rb so that it can be run outside of the test directory
192
+ more easily.
193
+
194
+ == 0.4.0 - 9-Feb-2004
195
+ * Changed "worker" method to "service_main" method.
196
+ * Added event hooks for stop, pause, resume, etc. See the documentation for
197
+ further details. (Thanks Park Heesob)
198
+ * Some of the Daemon functions were raising ServiceError. They have been
199
+ changed to DaemonError.
200
+ * Updated the daemon_test.rb file to use the new event hooks.
201
+ * Documentation additions and updates.
202
+
203
+ == 0.3.0 - 31-Jan-2004
204
+ * Added a Daemon subclass. This allows you to run Ruby programs as a service.
205
+ Please see the documentation for more details. (Thanks Park Heesob). This
206
+ should be considered an ALPHA release.
207
+ * The Win32ServiceError class has been renamed to just ServiceError. I felt
208
+ the "Win32" was redundant, given that it's already under the Win32 module.
209
+ * In some cases a bogus error description was being returned because the
210
+ GetLastError() function was being called too late. This has been fixed.
211
+ (Thanks Park Heesob).
212
+ * The explicit garbage collection has been removed because what I thought was
213
+ a memory leak was not, in fact, a memory leak. In addition, it was hurting
214
+ performance badly.
215
+ * The "\r\n" is now automatically stripped from error messages. This was
216
+ causing slightly garbled error messages. (Thanks Park Heesob).
217
+ * Added explicit closing of the Service Control Manager handle in the
218
+ services() function for those rare cases where it may fail while reading
219
+ service information.
220
+ * Made some of the error strings a bit more descriptive.
221
+ * Test suite and documentation additions, including a sample daemon program
222
+ in the test directory called "daemon_test.rb".
223
+
224
+ == 0.2.2 - 15-Jan-2004
225
+ * Fixed a mistake in the service_init declaration within Init_service().
226
+ * Fixed bug in the service_init function with regards to desired access.
227
+ * Modified service_free() function to explicitly set the hSCManager handle
228
+ to NULL and modified the service_close() method to test hSCManager handle
229
+ for NULL value. This should eliminate accidentally trying to close an
230
+ already closed handle, which may have happened as the result of a free()
231
+ call. (Thanks Park Heesob).
232
+ * Added explicit garbage collection in Service.services() method.
233
+ * More explicit about closing open HANDLE's when error conditions arise.
234
+
235
+ == 0.2.1 - 2-Nov-2003
236
+ * Made the exported less redundant and less verbose, e.g.
237
+ Service::SERVICE_DISABLED is now just Service::DISABLED. The same is true
238
+ for the service control constants, i.e. the 'SC_' has been removed.
239
+ * Corresponding test suite changes.
240
+
241
+ == 0.2.0 - 16-Oct-2003
242
+ * The constructor has been changed. It now only takes a machine name and a
243
+ desired access for arguments. The keyword arguments are now part of the
244
+ create_service method() and only in block form. See the documentation for
245
+ more details.
246
+ * Added a configure_service() and close() instance methods.
247
+ * Added several new constants to allow finer control over created and
248
+ configured services.
249
+ * Added Win32ServiceError as an exception. All failures now raise this
250
+ error instead of a vanilla StandardError.
251
+ * Moved some common code into the service.h file.
252
+
253
+ == 0.1.0 - 10-Oct-2003
254
+ - Initial release
@@ -0,0 +1,19 @@
1
+ * MANIFEST
2
+ * CHANGES
3
+ * README
4
+ * Rakefile
5
+ * win32-service.gemspec
6
+ * doc/daemon.txt
7
+ * doc/service.txt
8
+ * ext/extconf.rb
9
+ * ext/win32/daemonc.c
10
+ * examples/demo_daemon.rb
11
+ * examples/demo_daemon_ctl.rb
12
+ * examples/demo_services.rb
13
+ * lib/win32/service.rb
14
+ * test/test_win32_daemon.rb
15
+ * test/test_win32_service_configure.rb
16
+ * test/test_win32_service_create.rb
17
+ * test/test_win32_service_info.rb
18
+ * test/test_win32_service_status.rb
19
+ * test/test_win32_service.rb
data/README ADDED
@@ -0,0 +1,71 @@
1
+ == Description
2
+ The win32-service library allows you to control or create MS Windows services.
3
+
4
+ == Installation
5
+ gem install win32-service # Build from source
6
+ gem install win32-service --platform x86-mingw32 # Install binary
7
+
8
+ == Synopsis
9
+ require 'win32/service'
10
+
11
+ # Iterate over the available services
12
+ Service.services do |service|
13
+ p service
14
+ end
15
+
16
+ == More Documentation
17
+ Please see the documentation in the 'doc' directory, or the gem documentation
18
+ that was installed when you installed this library as a gem.
19
+
20
+ == Known Issues
21
+ === Problem:
22
+ Service.delete causes "Unable to delete: The specified service has been
23
+ marked for deletion."
24
+
25
+ === Troubleshooting:
26
+ This can be caused by one of two things. Either you attempted to delete a
27
+ running service without stopping it first, or you have the Services
28
+ Administrative Tool (GUI) open. In the former case, the solution is to first
29
+ stop the service if it's running. In the latter, close the Services GUI
30
+ admin tool before deleting.
31
+
32
+ === Problem:
33
+ Service.start causes, "The service did not respond to the start or control
34
+ request in a timely fashion."
35
+
36
+ === Troubleshooting:
37
+ The best way to debug your services is to wrap your entire Daemon subclass
38
+ in a begin/end block and send error messages to a file. That should give a
39
+ good clue as to the nature of the problem. The most probable culprits are:
40
+
41
+ * You've tried to require a library that's not in your $LOAD_PATH. Make sure
42
+ that your require statements are inside the begin/rescue block so that you can
43
+ easily find those mistakes.
44
+
45
+ * Your have a bad binary path name. Be sure to use an absolute path name for
46
+ the binary path name, including the full path to the Ruby interpreter, e.g.
47
+ 'c:\ruby\bin\ruby' instead of just 'ruby'.
48
+
49
+ * You've got a syntax error in your code somewhere.
50
+
51
+ == See Also
52
+ ruby-wmi
53
+
54
+ == Future Plans
55
+ Pure Ruby Daemon class
56
+ Add service_session_change hook
57
+
58
+ == Copyright
59
+ (C) 2003-2011, Daniel J. Berger, All Rights Reserved
60
+
61
+ == License
62
+ Artistic 2.0
63
+
64
+ == Warranty
65
+ This package is provided "as is" and without any express or
66
+ implied warranties, including, without limitation, the implied
67
+ warranties of merchantability and fitness for a particular purpose.
68
+
69
+ == Authors
70
+ Daniel J. Berger
71
+ Park Heesob
@@ -0,0 +1,179 @@
1
+ require 'rake'
2
+ require 'rake/clean'
3
+ require 'rake/testtask'
4
+ require 'rbconfig'
5
+ include Config
6
+
7
+ CLEAN.include(
8
+ '**/*.gem', # Gem files
9
+ '**/*.rbc', # Rubinius
10
+ '**/*.o', # C object file
11
+ '**/*.log', # Ruby extension build log
12
+ '**/Makefile', # C Makefile
13
+ "**/*.so", # C shared object
14
+ "**/*.lib", # C build file
15
+ "**/*.def", # C build file
16
+ "**/*.pdb", # C build file
17
+ "**/*.exp", # C build file
18
+ "**/*.obj", # C build file
19
+ "**/*.log", # C build file
20
+ "lib/win32/ruby18", "lib/win32/ruby19", "lib/win32/daemon.rb"
21
+ )
22
+
23
+ desc "Build the win32-service library"
24
+ task :build => [:clean] do
25
+ make = CONFIG['host_os'] =~ /mingw|cygwin/i ? "make" : "nmake"
26
+
27
+ Dir.chdir('ext') do
28
+ ruby 'extconf.rb'
29
+ sh "#{make}"
30
+ FileUtils.cp('daemon.so', 'win32/daemon.so')
31
+ end
32
+ end
33
+
34
+ namespace 'gem' do
35
+ desc 'Build the gem'
36
+ task :create => [:clean] do
37
+ spec = eval(IO.read('win32-service.gemspec'))
38
+ Gem::Builder.new(spec).build
39
+ end
40
+
41
+ desc 'Install the gem'
42
+ task :install => [:create] do
43
+ file = Dir['*.gem'].first
44
+ sh "gem install #{file}"
45
+ end
46
+
47
+ desc 'Build a binary gem'
48
+ task :binary => [:build] do
49
+ mkdir_p 'lib/win32'
50
+ mv 'ext/win32/daemon.so', 'lib/win32/daemon.so'
51
+
52
+ spec = eval(IO.read('win32-service.gemspec'))
53
+ spec.extensions = nil
54
+ spec.platform = Gem::Platform::CURRENT
55
+
56
+ spec.files = spec.files.reject{ |f| f.include?('ext') }
57
+
58
+ Gem::Builder.new(spec).build
59
+ end
60
+
61
+ # This is for me, not for you.
62
+ desc 'Create a gem with binaries for 1.8 and 1.9'
63
+ task :binaries => [:clean] do
64
+ make = CONFIG['host_os'] =~ /mingw|cygwin/i ? "make" : "nmake"
65
+
66
+ mkdir_p "lib/win32/ruby18"
67
+ mkdir_p "lib/win32/ruby19"
68
+
69
+ Dir.chdir('ext') do
70
+ # Ruby 1.8
71
+ sh "C:\\ruby187\\bin\\ruby extconf.rb"
72
+ sh "#{make}"
73
+ mv 'daemon.so', '../lib/win32/ruby18'
74
+ sh "#{make} distclean"
75
+
76
+ # Ruby 1.9
77
+ sh "C:\\ruby192\\bin\\ruby extconf.rb"
78
+ sh "#{make}"
79
+ mv 'daemon.so', '../lib/win32/ruby19'
80
+ end
81
+
82
+ File.open("lib/win32/daemon.rb", "w"){ |fh|
83
+ fh.puts "if RUBY_VERSION.to_f >= 1.9"
84
+ fh.puts " require 'win32/ruby19/daemon'"
85
+ fh.puts "else"
86
+ fh.puts " require 'win32/ruby18/daemon'"
87
+ fh.puts "end"
88
+ }
89
+
90
+ spec = eval(IO.read('win32-service.gemspec'))
91
+ spec.extensions = nil
92
+ spec.platform = Gem::Platform::CURRENT
93
+
94
+ spec.files = spec.files.reject{ |f| f.include?('ext') }
95
+
96
+ spec.files += [
97
+ 'lib/win32/daemon.rb',
98
+ 'lib/win32/ruby18/daemon.so',
99
+ 'lib/win32/ruby19/daemon.so'
100
+ ]
101
+
102
+ Gem::Builder.new(spec).build
103
+ end
104
+ end
105
+
106
+ namespace :example do
107
+ desc "Run the services example program."
108
+ task :services do
109
+ sh "ruby -Ilib examples/demo_services.rb"
110
+ end
111
+ end
112
+
113
+ namespace 'test' do
114
+ desc 'Run all tests for the win32-service library'
115
+ Rake::TestTask.new('all') do |t|
116
+ task :all => :build
117
+ t.libs << 'ext'
118
+ t.verbose = true
119
+ t.warning = true
120
+ end
121
+
122
+ desc 'Run the tests for the Win32::Daemon class'
123
+ Rake::TestTask.new('daemon') do |t|
124
+ task :daemon => :build
125
+ t.libs << 'ext'
126
+ t.verbose = true
127
+ t.warning = true
128
+ t.test_files = FileList['test/test_win32_daemon.rb']
129
+ end
130
+
131
+ namespace 'service' do
132
+ desc 'Run the tests for the Win32::Service class'
133
+ Rake::TestTask.new('all') do |t|
134
+ t.verbose = true
135
+ t.warning = true
136
+ t.test_files = FileList['test/test_win32_service*.rb']
137
+ end
138
+
139
+ Rake::TestTask.new('configure') do |t|
140
+ t.verbose = true
141
+ t.warning = true
142
+ t.test_files = FileList['test/test_win32_service_configure.rb']
143
+ end
144
+
145
+ Rake::TestTask.new('control') do |t|
146
+ t.verbose = true
147
+ t.warning = true
148
+ t.test_files = FileList['test/test_win32_service.rb']
149
+ end
150
+
151
+ Rake::TestTask.new('create') do |t|
152
+ t.verbose = true
153
+ t.warning = true
154
+ t.test_files = FileList['test/test_win32_service_create.rb']
155
+ end
156
+
157
+ Rake::TestTask.new('info') do |t|
158
+ t.verbose = true
159
+ t.warning = true
160
+ t.test_files = FileList['test/test_win32_service_info.rb']
161
+ end
162
+
163
+ Rake::TestTask.new('status') do |t|
164
+ t.verbose = true
165
+ t.warning = true
166
+ t.test_files = FileList['test/test_win32_service_status.rb']
167
+ end
168
+ end
169
+
170
+ task :all do
171
+ Rake.application[:clean].execute
172
+ end
173
+
174
+ task :daemon do
175
+ Rake.application[:clean].execute
176
+ end
177
+ end
178
+
179
+ task :default => 'test:all'