win32-service 0.7.0-x86-mswin32-60 → 0.7.1-x86-mswin32-60
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGES +247 -238
- data/MANIFEST +18 -18
- data/README +74 -45
- data/Rakefile +139 -128
- data/doc/daemon.txt +157 -157
- data/doc/service.txt +365 -368
- data/examples/demo_daemon.rb +89 -89
- data/examples/demo_daemon_ctl.rb +122 -122
- data/examples/demo_services.rb +23 -23
- data/ext/win32/daemon.c +611 -596
- data/lib/win32/daemon.so +0 -0
- data/lib/win32/service.rb +1638 -1607
- data/test/test_win32_daemon.rb +58 -58
- data/test/test_win32_service.rb +409 -251
- data/test/test_win32_service_configure.rb +97 -86
- data/test/test_win32_service_create.rb +131 -103
- data/test/test_win32_service_info.rb +184 -179
- data/test/test_win32_service_status.rb +113 -111
- data/win32-service.gemspec +41 -49
- metadata +6 -6
data/MANIFEST
CHANGED
@@ -1,19 +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
|
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
19
|
* test/test_win32_service.rb
|
data/README
CHANGED
@@ -1,45 +1,74 @@
|
|
1
|
-
|
2
|
-
The win32-service library allows you to control or create MS Windows services.
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
*
|
45
|
-
|
1
|
+
== Description
|
2
|
+
The win32-service library allows you to control or create MS Windows services.
|
3
|
+
|
4
|
+
== Installation
|
5
|
+
gem install win32-service
|
6
|
+
|
7
|
+
== Synopsis
|
8
|
+
require 'win32/service'
|
9
|
+
|
10
|
+
# Iterate over the available services
|
11
|
+
Service.services do |service|
|
12
|
+
p service
|
13
|
+
end
|
14
|
+
|
15
|
+
== More Documentation
|
16
|
+
Please see the documentation in the 'doc' directory, or the gem documentation
|
17
|
+
that was installed when you installed this library as a gem.
|
18
|
+
|
19
|
+
== Known Issues
|
20
|
+
=== Problem:
|
21
|
+
Service.delete causes "Unable to delete: The specified service has been
|
22
|
+
marked for deletion."
|
23
|
+
|
24
|
+
=== Troubleshooting:
|
25
|
+
This can be caused by one of two things. Either you attempted to delete a
|
26
|
+
running service without stopping it first, or you have the Services
|
27
|
+
administrative tool (GUI) open. In the form case, the solution is to first
|
28
|
+
stop the service if it's running. In the latter, close the Services GUI
|
29
|
+
admin tool before deleting.
|
30
|
+
|
31
|
+
=== Problem:
|
32
|
+
Service.start causes, "The service did not respond to the start or control
|
33
|
+
request in a timely fashion."
|
34
|
+
|
35
|
+
=== Troubleshooting:
|
36
|
+
The best way to debug your services is to wrap your entire Daemon subclass
|
37
|
+
in a begin/end block and send error messages to a file. That should give a
|
38
|
+
good clue as to the nature of the problem. The most probable culprits are:
|
39
|
+
|
40
|
+
* You've tried to require a library that's not in your $LOAD_PATH. Make sure
|
41
|
+
that your require statements are inside the begin/rescue block so that you can
|
42
|
+
easily find those mistakes.
|
43
|
+
|
44
|
+
* Your have a bad binary path name. Be sure to use an absolute path name for
|
45
|
+
the binary path name, including the full path to the Ruby interpreter, e.g.
|
46
|
+
'c:\ruby\bin\ruby' instead of just 'ruby'.
|
47
|
+
|
48
|
+
* You've got a syntax error in your code somewhere.
|
49
|
+
|
50
|
+
== Possible test failures
|
51
|
+
The 'test_service_start_stop' test in the test_win32_service.rb file may
|
52
|
+
fail. This will happen if your W32Time service isn't running.
|
53
|
+
|
54
|
+
== See Also
|
55
|
+
ruby-wmi
|
56
|
+
|
57
|
+
== Future Plans
|
58
|
+
Pure Ruby Daemon class
|
59
|
+
Add service_session_change hook
|
60
|
+
|
61
|
+
== Copyright
|
62
|
+
(C) 2003-2010, Daniel J. Berger, All Rights Reserved
|
63
|
+
|
64
|
+
== License
|
65
|
+
Artistic 2.0
|
66
|
+
|
67
|
+
== Warranty
|
68
|
+
This package is provided "as is" and without any express or
|
69
|
+
implied warranties, including, without limitation, the implied
|
70
|
+
warranties of merchantability and fitness for a particular purpose.
|
71
|
+
|
72
|
+
== Authors
|
73
|
+
Daniel J. Berger
|
74
|
+
Park Heesob
|
data/Rakefile
CHANGED
@@ -1,128 +1,139 @@
|
|
1
|
-
require 'rake'
|
2
|
-
require 'rake/clean'
|
3
|
-
require 'rake/testtask'
|
4
|
-
require 'rbconfig'
|
5
|
-
include Config
|
6
|
-
|
7
|
-
desc "Cleans up the C related files created during the build"
|
8
|
-
task :clean do
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
end
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
1
|
+
require 'rake'
|
2
|
+
require 'rake/clean'
|
3
|
+
require 'rake/testtask'
|
4
|
+
require 'rbconfig'
|
5
|
+
include Config
|
6
|
+
|
7
|
+
desc "Cleans up the C related files created during the build"
|
8
|
+
task :clean do
|
9
|
+
Dir.chdir('ext') do
|
10
|
+
if File.exists?('daemon.o') || File.exists?('daemon.so')
|
11
|
+
sh 'nmake distclean'
|
12
|
+
end
|
13
|
+
File.delete('win32/daemon.so') if File.exists?('win32/daemon.so')
|
14
|
+
end
|
15
|
+
Dir['*.gem'].each{ |f| File.delete(f) }
|
16
|
+
File.delete('lib/win32/daemon.so') if File.exists?('lib/win32/daemon.so')
|
17
|
+
end
|
18
|
+
|
19
|
+
desc "Builds, but does not install, the win32-service library"
|
20
|
+
task :build => [:clean] do
|
21
|
+
Dir.chdir('ext') do
|
22
|
+
ruby 'extconf.rb'
|
23
|
+
sh 'nmake'
|
24
|
+
FileUtils.cp('daemon.so', 'win32/daemon.so')
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
desc "Install the win32-service library (non-gem)"
|
29
|
+
task :install => [:build] do
|
30
|
+
Dir.chdir('ext') do
|
31
|
+
sh 'nmake install'
|
32
|
+
end
|
33
|
+
install_dir = File.join(CONFIG['sitelibdir'], 'win32')
|
34
|
+
Dir.mkdir(install_dir) unless File.exists?(install_dir)
|
35
|
+
FileUtils.cp('lib/win32/service.rb', install_dir, :verbose => true)
|
36
|
+
end
|
37
|
+
|
38
|
+
desc 'Uninstall the win32-service library (non-gem)'
|
39
|
+
task :uninstall do
|
40
|
+
service = File.join(CONFIG['sitelibdir'], 'win32', 'service.rb')
|
41
|
+
FileUtils.rm(service, :verbose => true) if File.exists?(service)
|
42
|
+
|
43
|
+
daemon = File.join(CONFIG['sitearchdir'], 'win32', 'daemon.so')
|
44
|
+
FileUtils.rm(daemon, :verbose => true) if File.exists?(daemon)
|
45
|
+
end
|
46
|
+
|
47
|
+
namespace 'gem' do
|
48
|
+
desc 'Build the gem'
|
49
|
+
task :create => [:clean] do
|
50
|
+
spec = eval(IO.read('win32-service.gemspec'))
|
51
|
+
Gem::Builder.new(spec).build
|
52
|
+
end
|
53
|
+
|
54
|
+
desc 'Install the gem'
|
55
|
+
task :install => [:create] do
|
56
|
+
file = Dir['*.gem'].first
|
57
|
+
sh "gem install #{file}"
|
58
|
+
end
|
59
|
+
|
60
|
+
desc 'Build a binary gem'
|
61
|
+
task :binary => [:build] do
|
62
|
+
mkdir_p 'lib/win32'
|
63
|
+
mv 'ext/win32/daemon.so', 'lib/win32/daemon.so'
|
64
|
+
|
65
|
+
spec = eval(IO.read('win32-service.gemspec'))
|
66
|
+
spec.extensions = nil
|
67
|
+
spec.platform = Gem::Platform::CURRENT
|
68
|
+
|
69
|
+
spec.files = spec.files.reject{ |f| f.include?('ext') }
|
70
|
+
|
71
|
+
Gem::Builder.new(spec).build
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
namespace 'test' do
|
76
|
+
desc 'Run all tests for the win32-service library'
|
77
|
+
Rake::TestTask.new('all') do |t|
|
78
|
+
task :all => :build
|
79
|
+
t.libs << 'ext'
|
80
|
+
t.verbose = true
|
81
|
+
t.warning = true
|
82
|
+
end
|
83
|
+
|
84
|
+
desc 'Run the tests for the Win32::Daemon class'
|
85
|
+
Rake::TestTask.new('daemon') do |t|
|
86
|
+
task :daemon => :build
|
87
|
+
t.libs << 'ext'
|
88
|
+
t.verbose = true
|
89
|
+
t.warning = true
|
90
|
+
t.test_files = FileList['test/test_win32_daemon.rb']
|
91
|
+
end
|
92
|
+
|
93
|
+
namespace 'service' do
|
94
|
+
desc 'Run the tests for the Win32::Service class'
|
95
|
+
Rake::TestTask.new('all') do |t|
|
96
|
+
t.verbose = true
|
97
|
+
t.warning = true
|
98
|
+
t.test_files = FileList['test/test_win32_service*.rb']
|
99
|
+
end
|
100
|
+
|
101
|
+
Rake::TestTask.new('configure') do |t|
|
102
|
+
t.verbose = true
|
103
|
+
t.warning = true
|
104
|
+
t.test_files = FileList['test/test_win32_service_configure.rb']
|
105
|
+
end
|
106
|
+
|
107
|
+
Rake::TestTask.new('control') do |t|
|
108
|
+
t.verbose = true
|
109
|
+
t.warning = true
|
110
|
+
t.test_files = FileList['test/test_win32_service.rb']
|
111
|
+
end
|
112
|
+
|
113
|
+
Rake::TestTask.new('create') do |t|
|
114
|
+
t.verbose = true
|
115
|
+
t.warning = true
|
116
|
+
t.test_files = FileList['test/test_win32_service_create.rb']
|
117
|
+
end
|
118
|
+
|
119
|
+
Rake::TestTask.new('info') do |t|
|
120
|
+
t.verbose = true
|
121
|
+
t.warning = true
|
122
|
+
t.test_files = FileList['test/test_win32_service_info.rb']
|
123
|
+
end
|
124
|
+
|
125
|
+
Rake::TestTask.new('status') do |t|
|
126
|
+
t.verbose = true
|
127
|
+
t.warning = true
|
128
|
+
t.test_files = FileList['test/test_win32_service_status.rb']
|
129
|
+
end
|
130
|
+
end
|
131
|
+
|
132
|
+
task :all do
|
133
|
+
Rake.application[:clean].execute
|
134
|
+
end
|
135
|
+
|
136
|
+
task :daemon do
|
137
|
+
Rake.application[:clean].execute
|
138
|
+
end
|
139
|
+
end
|
data/doc/daemon.txt
CHANGED
@@ -1,157 +1,157 @@
|
|
1
|
-
= Description
|
2
|
-
The Daemon class is a wrapper class that allows you to run your code as a
|
3
|
-
Windows service.
|
4
|
-
|
5
|
-
= Synopsis
|
6
|
-
class Daemon
|
7
|
-
def service_main
|
8
|
-
while running?
|
9
|
-
sleep 3
|
10
|
-
File.open("c:\\test.log", "a"){ |f| f.puts "service is running" }
|
11
|
-
end
|
12
|
-
end
|
13
|
-
end
|
14
|
-
|
15
|
-
Daemon.mainloop
|
16
|
-
|
17
|
-
= Class Methods
|
18
|
-
Daemon.mainloop
|
19
|
-
This is the method that actually puts your code into a loop and allows it
|
20
|
-
to run as a service. The code that is actually run while in the mainloop
|
21
|
-
is what you defined in the Daemon#service_main method.
|
22
|
-
|
23
|
-
= Instance Methods
|
24
|
-
Daemon#running?
|
25
|
-
Returns whether or not the daemon is running. This is just a shortcut
|
26
|
-
for checking if the state is RUNNING, PAUSED or IDLE.
|
27
|
-
|
28
|
-
This is typically used within your service_main method. See the
|
29
|
-
demo_daemon.rb file in the 'examples' directory for an example of how it's
|
30
|
-
used in practice.
|
31
|
-
|
32
|
-
Daemon#service_init
|
33
|
-
Any code defined defined within this method occurs before service_main is
|
34
|
-
reached. Any initialization code that takes more than two seconds to
|
35
|
-
execute should be placed here. Otherwise, your service may timeout when
|
36
|
-
you try to start it.
|
37
|
-
|
38
|
-
Daemon#service_main(*args)
|
39
|
-
You are expected to define your own service_main() method. The code
|
40
|
-
defined in this method is the code that will run while running as a
|
41
|
-
service.
|
42
|
-
|
43
|
-
Any +args+ passed to Service.start are passed to this method.
|
44
|
-
|
45
|
-
Daemon#state
|
46
|
-
Returns the current state of the Daemon. For a list of valid states, see
|
47
|
-
the Constants section below.
|
48
|
-
|
49
|
-
= Signal Event Hooks
|
50
|
-
These methods are called if defined within your Daemon class, and the
|
51
|
-
appropriate signal is received by your service.
|
52
|
-
|
53
|
-
Daemon#service_stop
|
54
|
-
Called if the service receives a SERVICE_CONTROL_STOP signal. This is
|
55
|
-
what the Service.stop() method sends.
|
56
|
-
|
57
|
-
Daemon#service_pause
|
58
|
-
Called if the service receives a SERVICE_CONTROL_PAUSE signal. This is
|
59
|
-
what the Service.pause() method sends.
|
60
|
-
|
61
|
-
Daemon#service_resume
|
62
|
-
Called if the service receives a SERVICE_CONTROL_CONTINUE signal. This
|
63
|
-
is what the Service.resume() method sends.
|
64
|
-
|
65
|
-
Daemon#service_interrogate
|
66
|
-
Called if the service receives a SERVICE_CONTROL_INTERROGATE signal. This
|
67
|
-
notifies a service that it should report its current status information to
|
68
|
-
the service control manager.
|
69
|
-
|
70
|
-
Daemon#service_shutdown
|
71
|
-
Called if the service receives a SERVICE_CONTROL_SHUTDOWN signal.
|
72
|
-
|
73
|
-
Daemon#service_netbindadd
|
74
|
-
Called if the service receives a SERVICE_CONTROL_NETBINDADD signal. This
|
75
|
-
notifies a network service that there is a new component for binding.
|
76
|
-
|
77
|
-
Daemon#service_netbinddisable
|
78
|
-
Called if the service receives a SERVICE_CONTROL_NETBINDDISABLE signal.
|
79
|
-
This notifies a network service that one of its bindings has been
|
80
|
-
disabled.
|
81
|
-
|
82
|
-
Daemon#service_netbindenable
|
83
|
-
Called if the service receives a SERVICE_CONTROL_NETBINDENABLE signal.
|
84
|
-
This Notifies a network service that a disabled binding has been enabled.
|
85
|
-
|
86
|
-
Daemon#service_netbindremove
|
87
|
-
Called if the service receives a SERVICE_CONTROL_NETBINDREMOVE signal.
|
88
|
-
This notifies a network service that that a component for binding has
|
89
|
-
been removed.
|
90
|
-
|
91
|
-
Daemon#service_paramchange
|
92
|
-
Called if the service receives a SERVICE_CONTROL_PARAMCHANGE signal.
|
93
|
-
This notifies a service that its startup parameters have changed.
|
94
|
-
|
95
|
-
= Constants
|
96
|
-
|
97
|
-
=== Service state constants
|
98
|
-
Daemon::CONTINUE_PENDING
|
99
|
-
The service continue is pending.
|
100
|
-
|
101
|
-
Daemon::PAUSE_PENDING
|
102
|
-
The service pause is pending.
|
103
|
-
|
104
|
-
Daemon::PAUSED
|
105
|
-
The service is paused (but not STOPPED).
|
106
|
-
|
107
|
-
Daemon::RUNNING
|
108
|
-
The service is running.
|
109
|
-
|
110
|
-
Daemon::START_PENDING
|
111
|
-
The service is starting (but is not yet in a RUNNING state).
|
112
|
-
|
113
|
-
Daemon::STOP_PENDING
|
114
|
-
The service is stopping (but is not yet in a STOPPED state).
|
115
|
-
|
116
|
-
Daemon::STOPPED
|
117
|
-
The service is not running.
|
118
|
-
|
119
|
-
Daemon::IDLE
|
120
|
-
The service is running, in an idle state. This is a custom state that
|
121
|
-
we added that gets around a thread blocking issue.
|
122
|
-
|
123
|
-
= Notes
|
124
|
-
You must create a service before you can actually run it. Look in the
|
125
|
-
examples directory for the files 'demo_daemon.rb' and 'demodaemon_ctl.rb'.
|
126
|
-
They're small and straightforward examples of how to control, install and
|
127
|
-
setup your own Daemon.
|
128
|
-
|
129
|
-
= Known Bugs
|
130
|
-
None known. Please report any bugs you find on the Bug tracker at
|
131
|
-
http://rubyforge.org/projects/win32utils.
|
132
|
-
|
133
|
-
= Future Plans
|
134
|
-
Rewrite the Daemon class in pure Ruby.
|
135
|
-
|
136
|
-
Suggestions welcome. Please log them on the Feature Request tracker at
|
137
|
-
http://rubyforge.org/projects/win32utils
|
138
|
-
|
139
|
-
= Acknowledgements
|
140
|
-
Many thanks go to Patrick Hurley for providing the fix for the thread
|
141
|
-
blocking issue. Thanks also go to Kevin Burge for his patch that solved
|
142
|
-
service responsiveness issues.
|
143
|
-
|
144
|
-
= Copyright
|
145
|
-
(C) 2003-2009 Daniel J. Berger, All Rights Reserved
|
146
|
-
|
147
|
-
= License
|
148
|
-
Artistic 2.0
|
149
|
-
|
150
|
-
= Warranty
|
151
|
-
This package is provided "as is" and without any express or
|
152
|
-
implied warranties, including, without limitation, the implied
|
153
|
-
warranties of merchantability and fitness for a particular purpose.
|
154
|
-
|
155
|
-
= Author(s)
|
156
|
-
* Daniel J. Berger
|
157
|
-
* Park Heesob
|
1
|
+
= Description
|
2
|
+
The Daemon class is a wrapper class that allows you to run your code as a
|
3
|
+
Windows service.
|
4
|
+
|
5
|
+
= Synopsis
|
6
|
+
class Daemon
|
7
|
+
def service_main
|
8
|
+
while running?
|
9
|
+
sleep 3
|
10
|
+
File.open("c:\\test.log", "a"){ |f| f.puts "service is running" }
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
Daemon.mainloop
|
16
|
+
|
17
|
+
= Class Methods
|
18
|
+
Daemon.mainloop
|
19
|
+
This is the method that actually puts your code into a loop and allows it
|
20
|
+
to run as a service. The code that is actually run while in the mainloop
|
21
|
+
is what you defined in the Daemon#service_main method.
|
22
|
+
|
23
|
+
= Instance Methods
|
24
|
+
Daemon#running?
|
25
|
+
Returns whether or not the daemon is running. This is just a shortcut
|
26
|
+
for checking if the state is RUNNING, PAUSED or IDLE.
|
27
|
+
|
28
|
+
This is typically used within your service_main method. See the
|
29
|
+
demo_daemon.rb file in the 'examples' directory for an example of how it's
|
30
|
+
used in practice.
|
31
|
+
|
32
|
+
Daemon#service_init
|
33
|
+
Any code defined defined within this method occurs before service_main is
|
34
|
+
reached. Any initialization code that takes more than two seconds to
|
35
|
+
execute should be placed here. Otherwise, your service may timeout when
|
36
|
+
you try to start it.
|
37
|
+
|
38
|
+
Daemon#service_main(*args)
|
39
|
+
You are expected to define your own service_main() method. The code
|
40
|
+
defined in this method is the code that will run while running as a
|
41
|
+
service.
|
42
|
+
|
43
|
+
Any +args+ passed to Service.start are passed to this method.
|
44
|
+
|
45
|
+
Daemon#state
|
46
|
+
Returns the current state of the Daemon. For a list of valid states, see
|
47
|
+
the Constants section below.
|
48
|
+
|
49
|
+
= Signal Event Hooks
|
50
|
+
These methods are called if defined within your Daemon class, and the
|
51
|
+
appropriate signal is received by your service.
|
52
|
+
|
53
|
+
Daemon#service_stop
|
54
|
+
Called if the service receives a SERVICE_CONTROL_STOP signal. This is
|
55
|
+
what the Service.stop() method sends.
|
56
|
+
|
57
|
+
Daemon#service_pause
|
58
|
+
Called if the service receives a SERVICE_CONTROL_PAUSE signal. This is
|
59
|
+
what the Service.pause() method sends.
|
60
|
+
|
61
|
+
Daemon#service_resume
|
62
|
+
Called if the service receives a SERVICE_CONTROL_CONTINUE signal. This
|
63
|
+
is what the Service.resume() method sends.
|
64
|
+
|
65
|
+
Daemon#service_interrogate
|
66
|
+
Called if the service receives a SERVICE_CONTROL_INTERROGATE signal. This
|
67
|
+
notifies a service that it should report its current status information to
|
68
|
+
the service control manager.
|
69
|
+
|
70
|
+
Daemon#service_shutdown
|
71
|
+
Called if the service receives a SERVICE_CONTROL_SHUTDOWN signal.
|
72
|
+
|
73
|
+
Daemon#service_netbindadd
|
74
|
+
Called if the service receives a SERVICE_CONTROL_NETBINDADD signal. This
|
75
|
+
notifies a network service that there is a new component for binding.
|
76
|
+
|
77
|
+
Daemon#service_netbinddisable
|
78
|
+
Called if the service receives a SERVICE_CONTROL_NETBINDDISABLE signal.
|
79
|
+
This notifies a network service that one of its bindings has been
|
80
|
+
disabled.
|
81
|
+
|
82
|
+
Daemon#service_netbindenable
|
83
|
+
Called if the service receives a SERVICE_CONTROL_NETBINDENABLE signal.
|
84
|
+
This Notifies a network service that a disabled binding has been enabled.
|
85
|
+
|
86
|
+
Daemon#service_netbindremove
|
87
|
+
Called if the service receives a SERVICE_CONTROL_NETBINDREMOVE signal.
|
88
|
+
This notifies a network service that that a component for binding has
|
89
|
+
been removed.
|
90
|
+
|
91
|
+
Daemon#service_paramchange
|
92
|
+
Called if the service receives a SERVICE_CONTROL_PARAMCHANGE signal.
|
93
|
+
This notifies a service that its startup parameters have changed.
|
94
|
+
|
95
|
+
= Constants
|
96
|
+
|
97
|
+
=== Service state constants
|
98
|
+
Daemon::CONTINUE_PENDING
|
99
|
+
The service continue is pending.
|
100
|
+
|
101
|
+
Daemon::PAUSE_PENDING
|
102
|
+
The service pause is pending.
|
103
|
+
|
104
|
+
Daemon::PAUSED
|
105
|
+
The service is paused (but not STOPPED).
|
106
|
+
|
107
|
+
Daemon::RUNNING
|
108
|
+
The service is running.
|
109
|
+
|
110
|
+
Daemon::START_PENDING
|
111
|
+
The service is starting (but is not yet in a RUNNING state).
|
112
|
+
|
113
|
+
Daemon::STOP_PENDING
|
114
|
+
The service is stopping (but is not yet in a STOPPED state).
|
115
|
+
|
116
|
+
Daemon::STOPPED
|
117
|
+
The service is not running.
|
118
|
+
|
119
|
+
Daemon::IDLE
|
120
|
+
The service is running, in an idle state. This is a custom state that
|
121
|
+
we added that gets around a thread blocking issue.
|
122
|
+
|
123
|
+
= Notes
|
124
|
+
You must create a service before you can actually run it. Look in the
|
125
|
+
examples directory for the files 'demo_daemon.rb' and 'demodaemon_ctl.rb'.
|
126
|
+
They're small and straightforward examples of how to control, install and
|
127
|
+
setup your own Daemon.
|
128
|
+
|
129
|
+
= Known Bugs
|
130
|
+
None known. Please report any bugs you find on the Bug tracker at
|
131
|
+
http://rubyforge.org/projects/win32utils.
|
132
|
+
|
133
|
+
= Future Plans
|
134
|
+
Rewrite the Daemon class in pure Ruby.
|
135
|
+
|
136
|
+
Suggestions welcome. Please log them on the Feature Request tracker at
|
137
|
+
http://rubyforge.org/projects/win32utils
|
138
|
+
|
139
|
+
= Acknowledgements
|
140
|
+
Many thanks go to Patrick Hurley for providing the fix for the thread
|
141
|
+
blocking issue. Thanks also go to Kevin Burge for his patch that solved
|
142
|
+
service responsiveness issues.
|
143
|
+
|
144
|
+
= Copyright
|
145
|
+
(C) 2003-2009 Daniel J. Berger, All Rights Reserved
|
146
|
+
|
147
|
+
= License
|
148
|
+
Artistic 2.0
|
149
|
+
|
150
|
+
= Warranty
|
151
|
+
This package is provided "as is" and without any express or
|
152
|
+
implied warranties, including, without limitation, the implied
|
153
|
+
warranties of merchantability and fitness for a particular purpose.
|
154
|
+
|
155
|
+
= Author(s)
|
156
|
+
* Daniel J. Berger
|
157
|
+
* Park Heesob
|