Skip to content

Commit

Permalink
[sre] updating command management to avoid waiting thread
Browse files Browse the repository at this point in the history
Update of the SREmain that was actively waiting the termination of all
running commands before do a system.exit. The active wait has been
removed as well as the system.exit.
  • Loading branch information
ngaud committed Jan 23, 2020
1 parent a12ce55 commit 220785d
Show file tree
Hide file tree
Showing 4 changed files with 2 additions and 17 deletions.
Expand Up @@ -64,8 +64,7 @@ class Boot {
*/
@SuppressWarnings("discouraged_reference")
static def main(args : String*) : void {
val retCode = createMainObject.runSRE(args)
System::exit(retCode)
val retCode = createMainObject.runSRE(args)
}

}
Expand Up @@ -166,16 +166,4 @@ abstract class AbstractRunCommand extends CommandWithMetadata {
bootstrap.startAgent(bootAgent, config.agentStartArgs)
}

/** Wait for the termination of the SRE execution.
* This function returns when the SRE is stopped.
*
* @param bootstrap the SRE bootstrap.
*/
@SuppressWarnings("discouraged_reference")
protected def waitForTermination(bootstrap : SREBootstrap) : void {
while (bootstrap.running) {
sleep(100)
}
}

}
Expand Up @@ -74,7 +74,6 @@ class RunSingleAgentCommand extends AbstractRunCommand {
}
var config = cli.synchronizeCliWithBootConfig(1)
bootstrap.startAgentsFromConfig(config)
bootstrap.waitForTermination
} catch (exception : Throwable) {
return CommandOutcome.failed(255,
MessageFormat::format(Messages::RunSingleAgentCommand_2, exception.localizedMessage), exception)
Expand Down
Expand Up @@ -73,8 +73,7 @@ class RunWithoutAgentCommand extends AbstractRunCommand {
val universeContext = sre.startWithoutAgent
if (universeContext === null) {
return CommandOutcome::failed(255, Messages::RunWithoutAgentCommand_3)
}
sre.waitForTermination
}
} catch (exception : Throwable) {
return CommandOutcome::failed(255, MessageFormat::format(Messages::RunWithoutAgentCommand_2, exception.localizedMessage), exception)
}
Expand Down

0 comments on commit 220785d

Please sign in to comment.