Skip to content

Commit d8c9c3e

Browse files
committed
remove: Jooby.start() fix #3704
1 parent 49fc58f commit d8c9c3e

File tree

2 files changed

+16
-40
lines changed

2 files changed

+16
-40
lines changed

jooby/src/main/java/io/jooby/Jooby.java

Lines changed: 16 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -954,40 +954,7 @@ public Jooby setStartupSummary(List<StartupSummary> startupSummary) {
954954
}
955955

956956
/**
957-
* Start application, find a web server, deploy application, start router, extension modules,
958-
* etc..
959-
*
960-
* @return Server.
961-
* @deprecated Use {@link Server#start(Jooby[])}
962-
*/
963-
@Deprecated(since = "3.8.0", forRemoval = true)
964-
public @NonNull Server start() {
965-
if (server == null) {
966-
this.server = Server.loadServer();
967-
}
968-
if (!server.getLoggerOff().isEmpty()) {
969-
this.server = MutedServer.mute(this.server);
970-
}
971-
try {
972-
return server.start(this);
973-
} catch (Throwable startupError) {
974-
stopped.set(true);
975-
Logger log = getLog();
976-
log.error("Application startup resulted in exception", startupError);
977-
try {
978-
server.stop();
979-
} catch (Throwable stopError) {
980-
log.debug("Server stop resulted in exception", stopError);
981-
}
982-
// rethrow
983-
throw startupError instanceof StartupException
984-
? (StartupException) startupError
985-
: new StartupException("Application startup resulted in exception", startupError);
986-
}
987-
}
988-
989-
/**
990-
* Call back method that indicates application was deploy it in the given server.
957+
* Call back method that indicates application was deployed.
991958
*
992959
* @param server Server.
993960
* @return This application.
@@ -1019,7 +986,7 @@ public Jooby setStartupSummary(List<StartupSummary> startupSummary) {
1019986
.orElseGet(() -> singletonList(Locale.getDefault()));
1020987
}
1021988

1022-
ServiceRegistry services = getServices();
989+
var services = getServices();
1023990
services.put(Environment.class, getEnvironment());
1024991
services.put(Config.class, getConfig());
1025992

@@ -1303,7 +1270,20 @@ public static void runApp(
13031270
});
13041271
apps.add(app);
13051272
}
1306-
targetServer.start(apps.toArray(new Jooby[0]));
1273+
try {
1274+
targetServer.start(apps.toArray(new Jooby[0]));
1275+
} catch (Throwable startupError) {
1276+
apps.forEach(app -> app.stopped.set(true));
1277+
try {
1278+
server.stop();
1279+
} catch (Throwable ignored) {
1280+
// no need to log here
1281+
}
1282+
// rethrow
1283+
throw startupError instanceof StartupException
1284+
? (StartupException) startupError
1285+
: new StartupException("Startup resulted in exception", startupError);
1286+
}
13071287
}
13081288

13091289
/**

tests/src/test/java/io/jooby/i3500/WidgetService.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,6 @@ public WidgetService() {
2424

2525
mount(new WidgetRouter());
2626
}
27-
28-
public static void main(String[] args) {
29-
new WidgetService().start();
30-
}
3127
}
3228

3329
class WidgetRouter extends Jooby {

0 commit comments

Comments
 (0)