We have an automated deployment process which is primarily managed by a batch file. One of the first steps in that process is to stop an IIS AppPool so the updated files can be safely copied. To do this, we call PsExec, like this:
PsExec.exe -accepteula %WEB_SERVER_MACHINE_NAME% cmd /c %%systemroot%%\system32\inetsrv\AppCmd.exe stop apppool /apppool.name:"%APP_POOL_NAME%" 2>&1
Where the environment variables are (these are not the actual values, just for illustration):
WEB_SERVER_MACHINE_NAME=\\WEBSERVER01
APP_POOL_NAME=APP01
The entire deployment process usually takes just a few minutes. However, it seems that sometimes, seemingly at random, this process gets stuck at this step and seems to wait indefinitely. If I check the web server during this process, AppPool
is not stopped, and manually stopping the AppPool
has no effect. There are 6 different sites that need to be deployed and this can happen on any one of the sites.
I have also tried disabling auto-start like this:
PsExec.exe -accepteula %WEB_SERVER_MACHINE_NAME% cmd /c %%systemroot%%\system32\inetsrv\AppCmd.exe set apppool /apppool.name:"%APP_POOL_NAME%" /autoStart:false 2>&1
And occasionally, but it seems to get stalled at this step sometimes. So, it seems to be an issue with PsExec
rather than AppCmd
. I have also tried specifying a connection timeout to PsExec
as well as chaining an exit at the end of the cmd
call, like this:
PsExec.exe -accepteula -n 60 %WEB_SERVER_MACHINE_NAME% cmd /c %%systemroot%%\system32\inetsrv\AppCmd.exe stop apppool /apppool.name:"%APP_POOL_NAME%" ^& exit 0 2>&1
Has anyone encountered this issue before? What could cause this PsExec
call to stall intermittently?