Simply abstracts the common stuff that the config tool needs to do when dealing with Win32. It is a very thin wrapper which may expand later.
Deletes the service from the system. It first tries to stop the service, and if you pass in a block it will call it while the service is being stopped.
# File lib/mongrel_config/win32.rb, line 71 71: def W32Support.delete(service_name) 72: begin 73: W32Support.stop(service_name) do |status| 74: yield status if block_given? 75: end 76: rescue 77: end 78: 79: begin 80: Win32::Service.delete(service_name) 81: rescue 82: end 83: end
Just gets the display name of the service.
# File lib/mongrel_config/win32.rb, line 16 16: def W32Support.display(name) 17: Win32::Service.getdisplayname(name) 18: end
Performs one operations (like :start or :start) which need to be “monitored” until they’re done. The wait_for parameter should be a regex for the content of the status like /running/ or /stopped/
# File lib/mongrel_config/win32.rb, line 24 24: def W32Support.do_and_wait(service_name, operation, wait_for) 25: status = W32Support.status(service_name) 26: if status =~ wait_for 27: # already running call the block once and leave 28: yield status 29: else 30: # start trying to start it 31: Win32::Service.send(operation, service_name) 32: status = W32Support.status(service_name) 33: while status !~ wait_for 34: yield status 35: status = W32Support.status(service_name) 36: end 37: 38: # do one last yield so they know it started 39: yield status 40: end 41: end
Lists all of the services that have “mongrel” in the binary_path_name of the service. This detects the mongrel services.
# File lib/mongrel_config/win32.rb, line 11 11: def W32Support.list 12: Win32::Service.services.select {|s| s.binary_path_name =~ /mongrel/ } 13: end
Starts the requested service and calls a passed in block until the service is done. You should sleep for a short period until it’s done or there’s an exception.
# File lib/mongrel_config/win32.rb, line 46 46: def W32Support.start(service_name) 47: W32Support.do_and_wait(service_name, :start, /running/) do |status| 48: yield status 49: end 50: end
Returns the current_state field of the service.
# File lib/mongrel_config/win32.rb, line 63 63: def W32Support.status(service_name) 64: Win32::Service.status(service_name).current_state 65: end
Stops the service. Just like W32Support.start is will call a block while it checks for the service to actually stop.
# File lib/mongrel_config/win32.rb, line 55 55: def W32Support.stop(service_name) 56: W32Support.do_and_wait(service_name, :stop, /stopped/) do |status| 57: yield status 58: end 59: end
Disabled; run with --debug to generate this.
Generated with the Darkfish Rdoc Generator 1.1.6.