Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@

package org.springframework.boot.devtools.restart;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import org.springframework.boot.context.event.ApplicationFailedEvent;
import org.springframework.boot.context.event.ApplicationPreparedEvent;
import org.springframework.boot.context.event.ApplicationReadyEvent;
Expand All @@ -35,10 +38,12 @@
public class RestartApplicationListener
implements ApplicationListener<ApplicationEvent>, Ordered {

private int order = HIGHEST_PRECEDENCE;

private static final String ENABLED_PROPERTY = "spring.devtools.restart.enabled";

private static final Log logger = LogFactory.getLog(RestartApplicationListener.class);

private int order = HIGHEST_PRECEDENCE;

@Override
public void onApplicationEvent(ApplicationEvent event) {
if (event instanceof ApplicationStartingEvent) {
Expand All @@ -63,10 +68,17 @@ private void onApplicationStartingEvent(ApplicationStartingEvent event) {
if (enabled == null || Boolean.parseBoolean(enabled)) {
String[] args = event.getArgs();
DefaultRestartInitializer initializer = new DefaultRestartInitializer();
boolean restartOnInitialize = !AgentReloader.isActive();
boolean restartOnInitialize = true;
if (AgentReloader.isActive()) {
logger.info(
"Restart disabled due to an agent-based reloader being active");
restartOnInitialize = false;
}
Restarter.initialize(args, false, initializer, restartOnInitialize);
}
else {
logger.info("Restart disabled due to System property '" + ENABLED_PROPERTY
+ "' set to false");
Restarter.disable();
}
}
Expand Down