【发布时间】:2017-10-26 10:28:27
【问题描述】:
我将应用程序作为一组 asp.net 微服务。 每个服务都由使用自托管 Web Api 的简单控制台应用程序提供。 我正在使用 Octopus Deploy 将这些服务部署到服务器。 Octopus为每个服务创建Windows调度任务并设置
$ExecutionTimeout = New-TimeSpan -Days 9999
我可以在已创建任务的 Windows 任务调度程序 UI 中找到相同的值。
我的问题是:工作一段时间(大约 2 周)后,我的所有服务都停止了。在我的服务中没有任何例外,而且它们同时都在下降。
我不知道为什么?我将执行时间设置为超过 20 年!!!! 此问题在不同的 Windows Server 版本上重现。
我还可以在我的任务历史日志中找到此事件:
Task Scheduler terminated "{CF7BA44C-CB14-4737-89B2-C7261CFC997E}" instance of the "\XXXX\XXX_SERVICE_NAME" task due to exceeding the time allocated for execution, as configured in the task definition. User Action: Increase the configured task timeout or investigate external reasons for the delay.
这是由 Octopus 执行的任务创建的 PowerShell 代码:
New-Item $InstallFolder -type directory
$FilePath = $InstallFolder + '\' + $ExecutableNameParam
$Action = New-ScheduledTaskAction -Execute $FilePath -WorkingDirectory $InstallFolder
$Trigger = New-ScheduledTaskTrigger -AtStartup
$RestartInterval = New-TimeSpan -minute 1
$ExecutionTimeout = New-TimeSpan -Days 9999
$Settings = New-ScheduledTaskSettingsSet -AllowStartIfOnBatteries -DontStopIfGoingOnBatteries -DontStopOnIdleEnd -RestartCount 10 -RestartInterval $RestartInterval -WakeToRun -StartWhenAvailable -ExecutionTimeLimit $ExecutionTimeout
$Principal = New-ScheduledTaskPrincipal -UserId "LOCALSERVICE" -LogonType ServiceAccount
Register-ScheduledTask -Action $Action -Trigger $Trigger -TaskName $TaskName -Settings $Settings -Principal $Principal
如果您认为我应该在这个问题中添加一些关于我的环境的额外信息,请在 cmets 中告诉我。
提前致谢。
统一更新: 我的触发器设置中也禁用了过期:
如果我理解正确,这意味着此触发器根本没有过期。
【问题讨论】:
-
也许这有一些信息:serverfault.com/questions/604083/… ?
-
我相信我已经正确配置了两个选项(如我所见)我明天早上会重新检查第二个
-
我现在有 utc+3 时间,以了解早上的时间。我是*的新手,它是否为用户提供时区?我找不到
-
Stack Overflow 不提供时区,但提供粗略的位置。我在 UTC-0500。
-
我已经检查了我的触发器设置的过期时间,它似乎是正确的。我已经相应地更新了问题
标签: .net windows scheduled-tasks continuous-deployment octopus-deploy