@@ -1079,6 +1079,22 @@ function Configure-Dockerd {
1079
1079
$STACKDRIVER_VERSION = ' v1-9'
1080
1080
$STACKDRIVER_ROOT = ' C:\Program Files (x86)\Stackdriver'
1081
1081
1082
+
1083
+ # Restart the Stackdriver logging agent
1084
+ # `Restart-Service StackdriverLogging` may fail because StackdriverLogging
1085
+ # sometimes is unstoppable, so we work around it by killing the processes.
1086
+ function Restart-StackdriverLoggingAgent {
1087
+ Stop-Service - NoWait StackdriverLogging
1088
+ # TODO: check periodically to lower the wait time
1089
+ Start-Sleep 10
1090
+ if ((Get-service StackdriverLogging).Status -ne ' Stopped' ) {
1091
+ # Force kill the processes.
1092
+ Stop-Process - Force - PassThru - Id (Get-WmiObject win32_process |
1093
+ Where CommandLine -Like ' *Stackdriver/logging*' ).ProcessId
1094
+ }
1095
+ Start-Service StackdriverLogging
1096
+ }
1097
+
1082
1098
# Install and start the Stackdriver logging agent according to
1083
1099
# https://cloud.google.com/logging/docs/agent/installation.
1084
1100
# TODO(yujuhong): Update to a newer Stackdriver agent once it is released to
@@ -1105,7 +1121,7 @@ function InstallAndStart-LoggingAgent {
1105
1121
" Stackdriver logging agent is already installed" )
1106
1122
# Restart-Service restarts a running service or starts a not-running
1107
1123
# service.
1108
- Restart-Service StackdriverLogging
1124
+ Restart-StackdriverLoggingAgent
1109
1125
return
1110
1126
}
1111
1127
@@ -1136,7 +1152,7 @@ function InstallAndStart-LoggingAgent {
1136
1152
- Encoding ASCII
1137
1153
1138
1154
# Restart the service to pick up the new configurations.
1139
- Restart-Service StackdriverLogging
1155
+ Restart-StackdriverLoggingAgent
1140
1156
Remove-Item - Force - Recurse $tmp_dir
1141
1157
}
1142
1158
0 commit comments