class BradyW::IIS

A task for starting/stopping IIS. The task will not fail if the service cannot be stopped successfully to avoid failing the build if IIS is already running.

Attributes

command[RW]

Required Command to execute, should be either :start or :stop

service[RW]

Optional Service to bounce, by default W3SVC will be bounced.

Private Instance Methods

exectask() click to toggle source

Create the tasks defined by this task lib.

   # File lib/iis.rb
18         def exectask
19     raise "You forgot to supply a service command (:start, :stop)" unless @command 
20                 puts "Starting/Stopping IIS Service"
21                 cmd = "net.exe #{@command} #{service}"                       
22                 shell cmd do |ok,status|
23                         ok or
24                         if @command == :stop
25                                 puts "Ignoring failure since we're stopping"
26                                 ok
27                         else                        
28                                 fail "Command failed with status (#{status.exitstatus}):"
29                         end
30                 end          
31 end