1

我正在使用 Windows Azure Cloud 运行一个站点。有没有办法每 20 分钟 ping 一次我的网站?我的网站流量很低,我需要一直阻止该网站启动和停止应用程序池。

4

2 回答 2

1

您可能能够设置 Cron 作业来执行 ping,查看任务“使用 Cron 作业服务调度 Windows Azure 网站”以获取示例

于 2012-10-26T19:00:53.407 回答
1

如果您使用的是完整的云服务(又名 Web 角色),您可以使用启动任务将应用程序池设置为永不关闭。该脚本以及我发现有用的一些其他 IIS 配置更改都可以做到这一点。

@ECHO OFF

@REM A file to flag that this script has already run
@REM because if we run it twice, it errors out and prevents the Azure role from starting properly
@REM %~n0 expands to the name of the currently executing file, without the extension
SET FLAGFILE=c:\%~n0-flag.txt

IF EXIST "%FLAGFILE%" (
  ECHO %FLAGFILE% exists, exiting startup script
  exit /B
) ELSE (
  date /t > %FLAGFILE%
)

@REM Enable IIS compression for application/json MIME type
@REM This will fail the second time you run it on a machine (eg, your desktop). So don't do that. 
%windir%\system32\inetsrv\appcmd.exe set config -section:system.webServer/httpCompression /+"dynamicTypes.[mimeType='application/json',enabled='True']" /commit:apphost
%windir%\system32\inetsrv\appcmd.exe set config -section:system.webServer/httpCompression /+"dynamicTypes.[mimeType='application/json; charset=utf-8',enabled='True']" /commit:apphost

@REM Set IIS to automatically start AppPools
%windir%\system32\inetsrv\appcmd.exe set config -section:applicationPools -applicationPoolDefaults.startMode:AlwaysRunning /commit:apphost

@REM Set IIS to not shut down idle AppPools
%windir%\system32\inetsrv\appcmd set config -section:applicationPools -applicationPoolDefaults.processModel.idleTimeout:00:00:00 /commit:apphost

@REM remove IIS response headers
%windir%\system32\inetsrv\appcmd.exe set config /section:httpProtocol /-customHeaders.[name='X-Powered-By']
于 2012-10-26T19:32:09.860 回答