mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-13 08:55:44 +01:00
Ensure that context is destroyed on restart
This commit is contained in:
@@ -35,7 +35,7 @@ import java.util.function.IntConsumer;
|
||||
* <p>
|
||||
* This is useful if an external mechanism is able to restart the process after it has exited.
|
||||
*/
|
||||
class ExitRestartStrategy implements RestartStrategy {
|
||||
class ExitRestartStrategy extends RestartStrategy {
|
||||
|
||||
private static final Logger LOG = LoggerFactory.getLogger(ExitRestartStrategy.class);
|
||||
|
||||
@@ -45,6 +45,8 @@ class ExitRestartStrategy implements RestartStrategy {
|
||||
|
||||
private IntConsumer exiter = System::exit;
|
||||
|
||||
private int exitCode;
|
||||
|
||||
ExitRestartStrategy() {
|
||||
}
|
||||
|
||||
@@ -54,12 +56,12 @@ class ExitRestartStrategy implements RestartStrategy {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void restart(InjectionContext context) {
|
||||
int exitCode = determineExitCode();
|
||||
|
||||
LOG.warn("destroy injection context");
|
||||
context.destroy();
|
||||
public void prepareRestart(InjectionContext context) {
|
||||
exitCode = determineExitCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void executeRestart(InjectionContext context) {
|
||||
LOG.warn("exit scm-manager with exit code {}", exitCode);
|
||||
exiter.accept(exitCode);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user