Method: Chef::Provider::Service::Windows#restart_service

Defined in:
lib/chef/provider/service/windows.rb

#restart_serviceObject



148
149
150
151
152
153
154
155
156
157
158
159
160
161
# File 'lib/chef/provider/service/windows.rb', line 148

def restart_service
  if Win32::Service.exists?(@new_resource.service_name)
    if @new_resource.restart_command
      logger.trace "#{@new_resource} restarting service using the given restart_command"
      shell_out!(@new_resource.restart_command)
    else
      stop_service
      start_service
    end
    @new_resource.updated_by_last_action(true)
  else
    logger.debug "#{@new_resource} does not exist - nothing to do"
  end
end