Skip to content

Commit 4f9616c

Browse files
committed
Change DockerComposeProperties shut down default to stop
Closes gh-35239
1 parent 6a39b49 commit 4f9616c

18 files changed

+157
-157
lines changed

spring-boot-project/spring-boot-docker-compose/src/main/java/org/springframework/boot/docker/compose/core/DockerCompose.java

+11-11
Original file line numberDiff line numberDiff line change
@@ -33,35 +33,35 @@
3333
public interface DockerCompose {
3434

3535
/**
36-
* Timeout duration used to request a forced shutdown.
36+
* Timeout duration used to request a forced stop.
3737
*/
38-
Duration FORCE_SHUTDOWN = Duration.ZERO;
38+
Duration FORCE_STOP = Duration.ZERO;
3939

4040
/**
41-
* Run {@code docker compose up} to startup services. Waits until all contains are
42-
* started and healthy.
41+
* Run {@code docker compose up} to create and start services. Waits until all
42+
* contains are started and healthy.
4343
* @param logLevel the log level used to report progress
4444
*/
4545
void up(LogLevel logLevel);
4646

4747
/**
48-
* Run {@code docker compose down} to shut down any running services.
49-
* @param timeout the amount of time to wait or {@link #FORCE_SHUTDOWN} to shut down
50-
* without waiting.
48+
* Run {@code docker compose down} to stop and remove any running services.
49+
* @param timeout the amount of time to wait or {@link #FORCE_STOP} to stop without
50+
* waiting.
5151
*/
5252
void down(Duration timeout);
5353

5454
/**
55-
* Run {@code docker compose start} to startup services. Waits until all contains are
55+
* Run {@code docker compose start} to start services. Waits until all containers are
5656
* started and healthy.
5757
* @param logLevel the log level used to report progress
5858
*/
5959
void start(LogLevel logLevel);
6060

6161
/**
62-
* Run {@code docker compose stop} to shut down any running services.
63-
* @param timeout the amount of time to wait or {@link #FORCE_SHUTDOWN} to shut down
64-
* without waiting.
62+
* Run {@code docker compose stop} to stop any running services.
63+
* @param timeout the amount of time to wait or {@link #FORCE_STOP} to stop without
64+
* waiting.
6565
*/
6666
void stop(Duration timeout);
6767

spring-boot-project/spring-boot-docker-compose/src/main/java/org/springframework/boot/docker/compose/lifecycle/DockerComposeLifecycleManager.java

+13-13
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@
2929
import org.springframework.boot.docker.compose.core.DockerCompose;
3030
import org.springframework.boot.docker.compose.core.DockerComposeFile;
3131
import org.springframework.boot.docker.compose.core.RunningService;
32-
import org.springframework.boot.docker.compose.lifecycle.DockerComposeProperties.Shutdown;
33-
import org.springframework.boot.docker.compose.lifecycle.DockerComposeProperties.Startup;
32+
import org.springframework.boot.docker.compose.lifecycle.DockerComposeProperties.Start;
33+
import org.springframework.boot.docker.compose.lifecycle.DockerComposeProperties.Stop;
3434
import org.springframework.boot.docker.compose.readiness.ServiceReadinessChecks;
3535
import org.springframework.context.ApplicationContext;
3636
import org.springframework.context.ApplicationListener;
@@ -89,30 +89,30 @@ class DockerComposeLifecycleManager {
8989
: new ServiceReadinessChecks(this.classLoader, applicationContext.getEnvironment(), binder);
9090
}
9191

92-
void startup() {
92+
void start() {
9393
if (!this.properties.isEnabled()) {
94-
logger.trace("Docker compose support not enabled");
94+
logger.trace("Docker Compose support not enabled");
9595
return;
9696
}
9797
if (this.skipCheck.shouldSkip(this.classLoader, this.properties.getSkip())) {
98-
logger.trace("Docker compose support skipped");
98+
logger.trace("Docker Compose support skipped");
9999
return;
100100
}
101101
DockerComposeFile composeFile = getComposeFile();
102102
Set<String> activeProfiles = this.properties.getProfiles().getActive();
103103
DockerCompose dockerCompose = getDockerCompose(composeFile, activeProfiles);
104104
if (!dockerCompose.hasDefinedServices()) {
105-
logger.warn(LogMessage.format("No services defined in docker compose file '%s' with active profiles %s",
105+
logger.warn(LogMessage.format("No services defined in Docker Compose file '%s' with active profiles %s",
106106
composeFile, activeProfiles));
107107
return;
108108
}
109109
LifecycleManagement lifecycleManagement = this.properties.getLifecycleManagement();
110-
Startup startup = this.properties.getStartup();
111-
Shutdown shutdown = this.properties.getShutdown();
112-
if (lifecycleManagement.shouldStartup() && !dockerCompose.hasRunningServices()) {
113-
startup.getCommand().applyTo(dockerCompose, startup.getLogLevel());
114-
if (lifecycleManagement.shouldShutdown()) {
115-
this.shutdownHandlers.add(() -> shutdown.getCommand().applyTo(dockerCompose, shutdown.getTimeout()));
110+
Start start = this.properties.getStart();
111+
Stop stop = this.properties.getStop();
112+
if (lifecycleManagement.shouldStart() && !dockerCompose.hasRunningServices()) {
113+
start.getCommand().applyTo(dockerCompose, start.getLogLevel());
114+
if (lifecycleManagement.shouldStop()) {
115+
this.shutdownHandlers.add(() -> stop.getCommand().applyTo(dockerCompose, stop.getTimeout()));
116116
}
117117
}
118118
List<RunningService> runningServices = new ArrayList<>(dockerCompose.getRunningServices());
@@ -124,7 +124,7 @@ void startup() {
124124
protected DockerComposeFile getComposeFile() {
125125
DockerComposeFile composeFile = (this.properties.getFile() != null)
126126
? DockerComposeFile.of(this.properties.getFile()) : DockerComposeFile.find(this.workingDirectory);
127-
logger.info(LogMessage.format("Found docker compose file '%s'", composeFile));
127+
logger.info(LogMessage.format("Found Docker Compose file '%s'", composeFile));
128128
return composeFile;
129129
}
130130

spring-boot-project/spring-boot-docker-compose/src/main/java/org/springframework/boot/docker/compose/lifecycle/DockerComposeListener.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ public void onApplicationEvent(ApplicationPreparedEvent event) {
5050
Binder binder = Binder.get(applicationContext.getEnvironment());
5151
DockerComposeProperties properties = DockerComposeProperties.get(binder);
5252
Set<ApplicationListener<?>> eventListeners = event.getSpringApplication().getListeners();
53-
createDockerComposeLifecycleManager(applicationContext, binder, properties, eventListeners).startup();
53+
createDockerComposeLifecycleManager(applicationContext, binder, properties, eventListeners).start();
5454
}
5555

5656
protected DockerComposeLifecycleManager createDockerComposeLifecycleManager(

spring-boot-project/spring-boot-docker-compose/src/main/java/org/springframework/boot/docker/compose/lifecycle/DockerComposeProperties.java

+18-18
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
import org.springframework.boot.logging.LogLevel;
2727

2828
/**
29-
* Configuration properties for the 'docker compose'.
29+
* Configuration properties for Docker Compose.
3030
*
3131
* @author Moritz Halbritter
3232
* @author Andy Wilkinson
@@ -61,12 +61,12 @@ public class DockerComposeProperties {
6161
/**
6262
* Start configuration.
6363
*/
64-
private final Startup startup = new Startup();
64+
private final Start start = new Start();
6565

6666
/**
6767
* Stop configuration.
6868
*/
69-
private final Shutdown shutdown = new Shutdown();
69+
private final Stop stop = new Stop();
7070

7171
/**
7272
* Profiles configuration.
@@ -107,12 +107,12 @@ public void setHost(String host) {
107107
this.host = host;
108108
}
109109

110-
public Startup getStartup() {
111-
return this.startup;
110+
public Start getStart() {
111+
return this.start;
112112
}
113113

114-
public Shutdown getShutdown() {
115-
return this.shutdown;
114+
public Stop getStop() {
115+
return this.stop;
116116
}
117117

118118
public Profiles getProfiles() {
@@ -128,25 +128,25 @@ static DockerComposeProperties get(Binder binder) {
128128
}
129129

130130
/**
131-
* Startup properties.
131+
* Start properties.
132132
*/
133-
public static class Startup {
133+
public static class Start {
134134

135135
/**
136136
* Command used to start docker compose.
137137
*/
138-
private StartupCommand command = StartupCommand.UP;
138+
private StartCommand command = StartCommand.UP;
139139

140140
/**
141141
* Log level for output.
142142
*/
143143
private LogLevel logLevel = LogLevel.INFO;
144144

145-
public StartupCommand getCommand() {
145+
public StartCommand getCommand() {
146146
return this.command;
147147
}
148148

149-
public void setCommand(StartupCommand command) {
149+
public void setCommand(StartCommand command) {
150150
this.command = command;
151151
}
152152

@@ -161,25 +161,25 @@ public void setLogLevel(LogLevel logLevel) {
161161
}
162162

163163
/**
164-
* Shutdown properties.
164+
* Stop properties.
165165
*/
166-
public static class Shutdown {
166+
public static class Stop {
167167

168168
/**
169169
* Command used to stop docker compose.
170170
*/
171-
private ShutdownCommand command = ShutdownCommand.DOWN;
171+
private StopCommand command = StopCommand.STOP;
172172

173173
/**
174-
* Timeout for stopping docker compose. Use '0' for forced stop.
174+
* Timeout for stopping Docker Compose. Use '0' for forced stop.
175175
*/
176176
private Duration timeout = Duration.ofSeconds(10);
177177

178-
public ShutdownCommand getCommand() {
178+
public StopCommand getCommand() {
179179
return this.command;
180180
}
181181

182-
public void setCommand(ShutdownCommand command) {
182+
public void setCommand(StopCommand command) {
183183
this.command = command;
184184
}
185185

spring-boot-project/spring-boot-docker-compose/src/main/java/org/springframework/boot/docker/compose/lifecycle/DockerComposeServicesReadyEvent.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@
2424
import org.springframework.context.ApplicationEvent;
2525

2626
/**
27-
* {@link ApplicationEvent} published when docker compose {@link RunningService} instances
28-
* are available. This event is published from the {@link ApplicationPreparedEvent} that
29-
* performs the docker compose startup.
27+
* {@link ApplicationEvent} published when Docker Compose {@link RunningService} instances
28+
* are available. This event is published from the {@link ApplicationPreparedEvent}
29+
* listener that starts Docker Compose.
3030
*
3131
* @author Moritz Halbritter
3232
* @author Andy Wilkinson

spring-boot-project/spring-boot-docker-compose/src/main/java/org/springframework/boot/docker/compose/lifecycle/DockerComposeSkipCheck.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
import org.springframework.util.ClassUtils;
2525

2626
/**
27-
* Checks if docker compose support should be skipped.
27+
* Checks if Docker Compose support should be skipped.
2828
*
2929
* @author Phillip Webb
3030
*/

spring-boot-project/spring-boot-docker-compose/src/main/java/org/springframework/boot/docker/compose/lifecycle/LifecycleManagement.java

+17-17
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
package org.springframework.boot.docker.compose.lifecycle;
1818

1919
/**
20-
* Docker compose lifecycle management.
20+
* Docker Compose lifecycle management.
2121
*
2222
* @author Moritz Halbritter
2323
* @author Andy Wilkinson
@@ -27,43 +27,43 @@
2727
public enum LifecycleManagement {
2828

2929
/**
30-
* Don't start or stop docker compose.
30+
* Don't start or stop Docker Compose.
3131
*/
3232
NONE(false, false),
3333

3434
/**
35-
* Only start docker compose if it's not running.
35+
* Start Docker Compose if it's not running.
3636
*/
3737
START_ONLY(true, false),
3838

3939
/**
40-
* Start and stop docker compose if it's not running.
40+
* Start Docker Compose if it's not running and stop it when the JVM exits.
4141
*/
4242
START_AND_STOP(true, true);
4343

44-
private final boolean startup;
44+
private final boolean start;
4545

46-
private final boolean shutdown;
46+
private final boolean stop;
4747

48-
LifecycleManagement(boolean startup, boolean shutdown) {
49-
this.startup = startup;
50-
this.shutdown = shutdown;
48+
LifecycleManagement(boolean start, boolean stop) {
49+
this.start = start;
50+
this.stop = stop;
5151
}
5252

5353
/**
54-
* Return whether docker compose should be started.
55-
* @return whether docker compose should be started
54+
* Return whether Docker Compose should be started.
55+
* @return whether Docker Compose should be started
5656
*/
57-
boolean shouldStartup() {
58-
return this.startup;
57+
boolean shouldStart() {
58+
return this.start;
5959
}
6060

6161
/**
62-
* Return whether docker compose should be stopped.
63-
* @return whether docker compose should be stopped
62+
* Return whether Docker Compose should be stopped.
63+
* @return whether Docker Compose should be stopped
6464
*/
65-
boolean shouldShutdown() {
66-
return this.shutdown;
65+
boolean shouldStop() {
66+
return this.stop;
6767
}
6868

6969
}
+5-5
Original file line numberDiff line numberDiff line change
@@ -22,28 +22,28 @@
2222
import org.springframework.boot.logging.LogLevel;
2323

2424
/**
25-
* Command used to startup docker compose.
25+
* Command used to start Docker Compose.
2626
*
2727
* @author Moritz Halbritter
2828
* @author Andy Wilkinson
2929
* @author Phillip Webb
3030
* @since 3.1.0
3131
*/
32-
public enum StartupCommand {
32+
public enum StartCommand {
3333

3434
/**
35-
* Startup using {@code docker compose up}.
35+
* Start using {@code docker compose up}.
3636
*/
3737
UP(DockerCompose::up),
3838

3939
/**
40-
* Startup using {@code docker compose start}.
40+
* Start using {@code docker compose start}.
4141
*/
4242
START(DockerCompose::start);
4343

4444
private final BiConsumer<DockerCompose, LogLevel> action;
4545

46-
StartupCommand(BiConsumer<DockerCompose, LogLevel> action) {
46+
StartCommand(BiConsumer<DockerCompose, LogLevel> action) {
4747
this.action = action;
4848
}
4949

Original file line numberDiff line numberDiff line change
@@ -22,28 +22,28 @@
2222
import org.springframework.boot.docker.compose.core.DockerCompose;
2323

2424
/**
25-
* Command used to shut down docker compose.
25+
* Command used to stop Docker Compose.
2626
*
2727
* @author Moritz Halbritter
2828
* @author Andy Wilkinson
2929
* @author Phillip Webb
3030
* @since 3.1.0
3131
*/
32-
public enum ShutdownCommand {
32+
public enum StopCommand {
3333

3434
/**
35-
* Shutdown using {@code docker compose down}.
35+
* Stop using {@code docker compose down}.
3636
*/
3737
DOWN(DockerCompose::down),
3838

3939
/**
40-
* Shutdown using {@code docker compose stop}.
40+
* Stop using {@code docker compose stop}.
4141
*/
4242
STOP(DockerCompose::stop);
4343

4444
private final BiConsumer<DockerCompose, Duration> action;
4545

46-
ShutdownCommand(BiConsumer<DockerCompose, Duration> action) {
46+
StopCommand(BiConsumer<DockerCompose, Duration> action) {
4747
this.action = action;
4848
}
4949

spring-boot-project/spring-boot-docker-compose/src/main/java/org/springframework/boot/docker/compose/lifecycle/package-info.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,6 @@
1515
*/
1616

1717
/**
18-
* Lifecycle management for docker compose with the context of a Spring application.
18+
* Lifecycle management for Docker Compose with the context of a Spring application.
1919
*/
2020
package org.springframework.boot.docker.compose.lifecycle;

0 commit comments

Comments
 (0)