mirror of
https://github.com/scm-manager/scm-manager.git
synced 2026-03-05 03:40:56 +01:00
Merge pull request #1308 from scm-manager/bugfix/wait_before_restart
wait before restart if system property "sonia.scm.restart.wait" is set
This commit is contained in:
@@ -31,9 +31,8 @@ import javax.inject.Singleton;
|
||||
|
||||
@Singleton
|
||||
public class DefaultRestarter implements Restarter {
|
||||
|
||||
private ScmEventBus eventBus;
|
||||
private RestartStrategy strategy;
|
||||
private final ScmEventBus eventBus;
|
||||
private final RestartStrategy strategy;
|
||||
|
||||
@Inject
|
||||
public DefaultRestarter() {
|
||||
|
||||
@@ -61,6 +61,7 @@ import static java.util.Comparator.comparing;
|
||||
class MigrationWizardServlet extends HttpServlet {
|
||||
|
||||
private static final Logger LOG = LoggerFactory.getLogger(MigrationWizardServlet.class);
|
||||
static final String PROPERTY_WAIT_TIME = "sonia.scm.restart-migration.wait";
|
||||
|
||||
private final XmlRepositoryV1UpdateStep repositoryV1UpdateStep;
|
||||
private final DefaultMigrationStrategyDAO migrationStrategyDao;
|
||||
@@ -129,7 +130,7 @@ class MigrationWizardServlet extends HttpServlet {
|
||||
|
||||
repositoryLineEntries.stream()
|
||||
.forEach(
|
||||
entry-> {
|
||||
entry -> {
|
||||
String id = entry.getId();
|
||||
String protocol = entry.getType();
|
||||
String originalName = entry.getOriginalName();
|
||||
@@ -145,7 +146,7 @@ class MigrationWizardServlet extends HttpServlet {
|
||||
|
||||
if (restarter.isSupported()) {
|
||||
respondWithTemplate(resp, model, "templates/repository-migration-restart.mustache");
|
||||
restarter.restart(MigrationWizardServlet.class, "wrote migration data");
|
||||
new Thread(this::restart).start();
|
||||
} else {
|
||||
respondWithTemplate(resp, model, "templates/repository-migration-manual-restart.mustache");
|
||||
LOG.error("Restarting is not supported on this platform.");
|
||||
@@ -153,6 +154,19 @@ class MigrationWizardServlet extends HttpServlet {
|
||||
}
|
||||
}
|
||||
|
||||
private void restart() {
|
||||
String wait = System.getProperty(PROPERTY_WAIT_TIME);
|
||||
if (!Strings.isNullOrEmpty(wait)) {
|
||||
try {
|
||||
Thread.sleep(Long.parseLong(wait));
|
||||
} catch (InterruptedException e) {
|
||||
LOG.error("error on waiting before restart", e);
|
||||
Thread.currentThread().interrupt();
|
||||
}
|
||||
}
|
||||
restarter.restart(MigrationWizardServlet.class, "wrote migration data");
|
||||
}
|
||||
|
||||
private List<RepositoryLineEntry> getRepositoryLineEntries() {
|
||||
List<V1Repository> repositoriesWithoutMigrationStrategies =
|
||||
repositoryV1UpdateStep.getRepositoriesWithoutMigrationStrategies();
|
||||
|
||||
Reference in New Issue
Block a user