82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
|
# File 'lib/chef/provider/service/windows.rb', line 82
def start_service
if Win32::Service.exists?(@new_resource.service_name)
configure_service_run_as_properties
state = current_state
if state == RUNNING
logger.debug "#{@new_resource} already started - nothing to do"
elsif state == START_PENDING
logger.trace "#{@new_resource} already sent start signal - waiting for start"
wait_for_state(RUNNING)
elsif state == STOPPED
if @new_resource.start_command
logger.trace "#{@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)
rescue SystemCallError => ex
if ex.errno == ERROR_SERVICE_LOGON_FAILED
logger.error ex.message
raise Chef::Exceptions::Service,
"Service #{@new_resource} did not start due to a logon failure (error #{ERROR_SERVICE_LOGON_FAILED}): possibly the specified user '#{@new_resource.run_as_user}' does not have the 'log on as a service' privilege, or the password is incorrect."
else
raise ex
end
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
logger.debug "#{@new_resource} does not exist - nothing to do"
end
end
|