Method: RunInBackground.start_win32service
- Defined in:
- lib/run_in_background.rb
.start_win32service(binary_path, binary_args, name, opts_specific = {}) ⇒ Object
Run in background script that was written as Windows Service, i.e. can receive signals from Service Control.
The code that is run in this script should be an extension of Win32::Daemon class.
For more information see Win32::Daemon help and examples.
No need to wrap such a script.
230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 |
# File 'lib/run_in_background.rb', line 230 def RunInBackground.start_win32service binary_path, binary_args, name, opts_specific = {} Log.debug1("executable that should be run as service: #{binary_path}") Log.debug1("arguments: #{binary_args}") Log.debug1("specific options: #{opts_specific}") if OS == :WINDOWS start_windows binary_path, binary_args, name, opts_specific else # OS == :LINUX raise NotImplementedError.new("Unsupported method on #{OS}") end 0.upto(TIMEOUT) do if exists?(name) && running?(name) puts "windows service #{name} started\n" Log.debug1("windows service #{name} started") return end sleep 1 end # if got here then something gone wrong and daemon/service wasn't started in timely manner delete name if exists? name Log.error("daemon/service #{name} wasn't started in timely manner") Log.flush raise "daemon/service #{name} wasn't started in timely manner" end |