Skip to content

Instantly share code, notes, and snippets.

@pkutaj
Last active February 24, 2021 09:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pkutaj/2de758d74a16a9db55337898e0956fec to your computer and use it in GitHub Desktop.
Save pkutaj/2de758d74a16a9db55337898e0956fec to your computer and use it in GitHub Desktop.
spagettiNomad
function get-nomadLogs ($jobId, $featureFlag) {
$nomadLogs = ($featureFlag -ne "e") ?
(nomad alloc logs -job $jobId) :
(nomad alloc logs -stderr -job $jobId)
if ($featureFlag -eq "l") { oh -InputObject $nomadLogs }
if (nomad status $jobID | sls -Pattern "(?=.*\d)failed") {
write-host "Job Failed - see webUI - stderr below" -ForegroundColor DarkRed
Pause
$nomadLogs = nomad alloc logs -stderr -job $jobId
oh -InputObject $nomadLogs
} elseif (nomad status $jobID | sls status.*dead) {
if ($featureFlag -eq "p") { oh -InputObject $nomadLogs -Paging }
else { oh -InputObject $nomadLogs }
} else { nomad status $jobID | sls status.*=.* }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment