Reputation: 3581
I have a chef recipe with the following code (commented out the alternate code that I tried as well)
#execute
# execute 'service-api install' do
# #command "web-#{node['default']['env']}.cmd" #start /HIGH /b -RedirectStandardOutput chef-serviceoutput.txt
# command ('powershell -c "start-process web-%s.cmd -RedirectStandardOutput C:\\buildinfo\\service-api\\api\\approot\\chef-serviceoutput.txt"' % node['default']['env'])
# cwd "C:\\buildinfo\\service-api\\api\\approot"
# #not_if :timeout => 10, :cwd => 'C:\\buildinfo\\service-api\\api\\approot'
# end
powershell_script 'service-api install' do
code <<-EOH
start-process web-#{node['default']['env']}.cmd -RedirectStandardOutput chef-serviceoutput.txt
EOH
cwd "C:\\buildinfo\\service-api\\api\\approot"
end
The code essentially changes working directory and runs a .cmd file which starts up a server. Now with start-process , it should open up a new cmd and then run the server there but in the original cmd it exits to a new line.
When I run this through chef, it (i think) is tracking all child cmd from the process as well and just gets stuck after running this section waiting for server to be killed.
Is there any way to work around it in chef/windows ??
Upvotes: 1
Views: 248
Reputation: 54247
You should probably be installing an actual service instead of trying to fork off background jobs from inside Chef. Check out the windows_service
resource.
Upvotes: 1