Win32::Service.get_start_type
Win32::Service.get_current_state
# File lib/chef/provider/service/windows.rb, line 145 def disable_service if Win32::Service.exists?(@new_resource.service_name) if start_type == AUTO_START Win32::Service.configure( :service_name => @new_resource.service_name, :start_type => Win32::Service::DISABLED ) @new_resource.updated_by_last_action(true) else Chef::Log.debug "#{@new_resource} already disabled - nothing to do" end else Chef::Log.debug "#{@new_resource} does not exist - nothing to do" end end
# File lib/chef/provider/service/windows.rb, line 129 def enable_service if Win32::Service.exists?(@new_resource.service_name) if start_type == AUTO_START Chef::Log.debug "#{@new_resource} already enabled - nothing to do" else Win32::Service.configure( :service_name => @new_resource.service_name, :start_type => Win32::Service::AUTO_START ) @new_resource.updated_by_last_action(true) end else Chef::Log.debug "#{@new_resource} does not exist - nothing to do" end end
# File lib/chef/provider/service/windows.rb, line 50 def load_current_resource @current_resource = Chef::Resource::Service.new(@new_resource.name) @current_resource.service_name(@new_resource.service_name) @current_resource.running(current_state == RUNNING) Chef::Log.debug "#{@new_resource} running: #{@current_resource.running}" @current_resource.enabled(start_type == AUTO_START) Chef::Log.debug "#{@new_resource} enabled: #{@current_resource.enabled}" @current_resource end
# File lib/chef/provider/service/windows.rb, line 114 def restart_service if Win32::Service.exists?(@new_resource.service_name) if @new_resource.restart_command Chef::Log.debug "#{@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 Chef::Log.debug "#{@new_resource} does not exist - nothing to do" end end
# File lib/chef/provider/service/windows.rb, line 60 def start_service if Win32::Service.exists?(@new_resource.service_name) state = current_state if state == RUNNING Chef::Log.debug "#{@new_resource} already started - nothing to do" elsif state == START_PENDING Chef::Log.debug "#{@new_resource} already sent start signal - waiting for start" wait_for_state(RUNNING) elsif state == STOPPED if @new_resource.start_command Chef::Log.debug "#{@new_resource} starting service using the given start_command" shell_out!(@new_resource.start_command) else spawn_command_thread do Win32::Service.start(@new_resource.service_name) end wait_for_state(RUNNING) end @new_resource.updated_by_last_action(true) else raise Chef::Exceptions::Service, "Service #{@new_resource} can't be started from state [#{state}]" end else Chef::Log.debug "#{@new_resource} does not exist - nothing to do" end end
# File lib/chef/provider/service/windows.rb, line 87 def stop_service if Win32::Service.exists?(@new_resource.service_name) state = current_state if state == RUNNING if @new_resource.stop_command Chef::Log.debug "#{@new_resource} stopping service using the given stop_command" shell_out!(@new_resource.stop_command) else spawn_command_thread do Win32::Service.stop(@new_resource.service_name) end wait_for_state(STOPPED) end @new_resource.updated_by_last_action(true) elsif state == STOPPED Chef::Log.debug "#{@new_resource} already stopped - nothing to do" elsif state == STOP_PENDING Chef::Log.debug "#{@new_resource} already sent stop signal - waiting for stop" wait_for_state(STOPPED) else raise Chef::Exceptions::Service, "Service #{@new_resource} can't be stopped from state [#{state}]" end else Chef::Log.debug "#{@new_resource} does not exist - nothing to do" end end
Generated with the Darkfish Rdoc Generator 2.