Azure start-up task hangs

↘锁芯ラ 提交于 2019-12-22 09:39:23

问题


I have an Azure project with an MVC4 role where I have added the Visual C++ 2012 Runtime Library setup file, and a script to silently install it.

The script works and the library gets installed, the only problem is that the task never finishes and the installation process never exits, which then blocks the role from starting:

I connected to the server using Remote Desktop, and by looking at the task manager I can see the process vcredist_x64.exe: (2 of them actually, but I think that's normal)

When I right-click and kill the process, the deployment finishes successfully and the role is started.

This is a problem when my start-up task is set to simple in ServiceDefinition.csdef, since that makes the server wait until the task is finished to start the role. So what I did was to set the task to background so the start-up script doesn't block the role from starting anymore, but even then the process is still running in the background and has to be killed manually.

This script should work, and has before with the 2010 VC++ library (Without the EXIT though, but that should be there as to avoid blocking the role if the script returns an error code):

vcredist_x64.exe /quiet /norestart
EXIT /B 0

Didn't work, so I thought I'd kill the process manually after the installation:

vcredist_x64.exe /quiet /norestart
TASKKILL /F /T /IM vcredist_x64.exe
EXIT /B 0

Didn't work, process was still alive. The script actually works if I run it manually myself on the server, or locally, but when Azure tries to do it during deployment it hangs.

My Start-up task is defined like this in ServiceDefinition.csdef:

<Startup>
  <Task commandLine="InstallVcRedist.cmd" executionContext="elevated" taskType="background" />
</Startup>

The logs in C:\Resources\temp\{RoleId.RoleName}\RoleTemp say everything went okay.

I can avoid the role from being blocked by setting the startup-task to background instead of simple, but that doesn't really solve the problem. Thanks.


回答1:


I figured out why this was happening, thanks to this blog post by Steve Marx.

This problem only occurs in Windows Server 2008 SP2, so I had to change the host to Windows Server 2008 R2.
This can be done by changing osFamily="1" to osFamily="2" in all of the ServiceConfiguration files, or it can be changed from the Azure portal by clicking on the service then Configure OS at the top.




回答2:


I needed to use this library as well. this is my script:

start /w
cd startup
vcredist_x64.exe /q /norestart

exit /b 0

it's working for me - startup is where i keep the vcredist_x64.exe.

on my servicedefinition file this is the xml line

 <Task commandLine="startup\InstallVcreditst.cmd" executionContext="elevated" taskType="simple" />


来源:https://stackoverflow.com/questions/12215672/azure-start-up-task-hangs

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!