For those interested, here's a powershell snippet that will start/restart the Jenkins slave service in case of termination: (NOTE: replace the $jenkins variable with the name of your Windows service name)

$DebugPreference = 2
$VerbosePreference = 2
$WarningPreference = 2

$jenkins = "jenkinsslave-c__Jenkins"
$now = (Get-Date).ToString()
$jenkinsService = Get-Service | Where-Object {($_.Name -eq $jenkins) -and ($_.Status -eq [System.ServiceProcess.ServiceControllerStatus]::Stopped)}

if ($jenkinsService.count -eq 1)

{ Write-Warning ($now + " Jenkins slave not running. Starting...") Start-Service $jenkins }

else
{

$errorLog = (Get-Content C:\Jenkins\jenkins-slave.err.log)[-1]
if ($errorLog.ToLower().CompareTo("info: terminated") -eq 0)

{ Write-Warning ($now + " Jenkins was terminated. Restarting...") Restart-Service $jenkins }

else

{ Write-Verbose ($now + " Jenkins slave is live and kicking!") }

}

This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators.
For more information on JIRA, see: http://www.atlassian.com/software/jira

--
You received this message because you are subscribed to the Google Groups "Jenkins Issues" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-issues+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Reply via email to