0

我们有一个 MVC 应用程序,我们正在使用 Jenkins 和 Octopus 进行部署。我们使用 Octopus 进行部署。有一个步骤是通过章鱼重启IIS。我们需要在部署后检查 IIS 是否已被 Octoups 重新启动。有没有我可以检查的日志或技术。

4

2 回答 2

0

有几个选项,例如在Octopus Deployiis 重置状态下捕获到变量中。或者从事件日志中获取有关上次 IIS 启动的信息。在此处输入图像描述

下面的 PS 脚本应该为您从事件日志中获取它时提供可能的解决方案:

$Events = Get-EventLog -LogName System -Source IISCTLS -Newest 1 -Message '*start command received*'
$DateTimeNow = Get-Date
if ($DateTimeNow.AddMinutes(-5) -lt  $Events.TimeGenerated){
    "happened less than 5 min ago"
}
else {
    "happened long ago"
}
于 2019-07-04T11:08:23.507 回答
0

您可以在章鱼中添加一个步骤,并使用before 和 after cmdletPoewrshell script添加/写入一些日志语句。Write-HostRestart-WebAppPool

这是您也可以添加的示例try catch代码

Write-Host "$(Get-Date -format "dd-MM-yyyy HH:mm:ss:ff") : Restarting Default App pool"
Restart-WebAppPool -Name "Default"
Write-Host "$(Get-Date -format "dd-MM-yyyy HH:mm:ss:ff") : Default App pool restarted"

输出如下:

04-07-2019 10:14:28:15 : Restarting Default App pool
04-07-2019 10:14:28:16 : Default App pool restarted

注意:您必须使用 Octopus 变量在运行时设置 AppPool 名称(动态)

于 2019-07-04T04:45:42.693 回答