mirror of
https://github.com/spring-projects/spring-boot.git
synced 2024-09-03 04:26:12 +08:00
Add Log Output when DevTools restart is disabled
This covers the cases when: * An Java agent based reloader (e.g. JRebel) is being used * The reloader was disabled by using a system property See gh-14807
This commit is contained in:
parent
35bd4cfbed
commit
e76605ff75
@ -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;
|
||||
@ -35,10 +38,12 @@ import org.springframework.core.Ordered;
|
||||
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) {
|
||||
@ -63,10 +68,17 @@ public class RestartApplicationListener
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user