CORDA-3924: Add a missing exit code for graceful shutdowns (#6695)

This commit is contained in:
Ryan Fowler 2020-09-09 14:08:42 +01:00 committed by GitHub
parent 6f2cac146c
commit 18a9545e07
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -643,7 +643,9 @@ object InteractiveShell {
}
@JvmStatic
fun gracefulShutdown(userSessionOut: RenderPrintWriter, cordaRPCOps: CordaRPCOps) {
fun gracefulShutdown(userSessionOut: RenderPrintWriter, cordaRPCOps: CordaRPCOps): Int {
var result = 0 // assume it all went well
fun display(statements: RenderPrintWriter.() -> Unit) {
statements.invoke(userSessionOut)
@ -688,13 +690,16 @@ object InteractiveShell {
// Cancelled whilst draining flows. So let's carry on from here
cordaRPCOps.setFlowsDrainingModeEnabled(false)
display { println("...cancelled clean shutdown.") }
result = 1
}
} catch (e: Exception) {
display { println("RPC failed: ${e.rootCause}", Color.red) }
result = 1
} finally {
InputStreamSerializer.invokeContext = null
InputStreamDeserializer.closeAll()
}
return result;
}
private fun printAndFollowRPCResponse(