|
27 | 27 | import org.slf4j.LoggerFactory; |
28 | 28 |
|
29 | 29 | import com.typesafe.config.Config; |
30 | | -import com.typesafe.config.ConfigFactory; |
31 | 30 | import edu.umd.cs.findbugs.annotations.NonNull; |
32 | 31 | import edu.umd.cs.findbugs.annotations.Nullable; |
33 | 32 | import io.jooby.exception.RegistryException; |
@@ -1200,12 +1199,7 @@ public static void runApp( |
1200 | 1199 | @NonNull String[] args, |
1201 | 1200 | @NonNull ExecutionMode executionMode, |
1202 | 1201 | @NonNull List<Supplier<Jooby>> provider) { |
1203 | | - var configMap = new HashMap<>(parseArguments(args)); |
1204 | | - // TODO: Add new way to override server options mainly from system properties/environment |
1205 | | - // variables. Probably by adding a new config file: server.conf |
1206 | | - // configMap.putAll(System.getenv()); |
1207 | | - var options = ServerOptions.from(ConfigFactory.parseMap(configMap)).orElse(new ServerOptions()); |
1208 | | - runApp(args, Server.loadServer(options), options, executionMode, provider); |
| 1202 | + runApp(args, Server.loadServer(), executionMode, provider); |
1209 | 1203 | } |
1210 | 1204 |
|
1211 | 1205 | /** |
@@ -1233,42 +1227,26 @@ public static void runApp( |
1233 | 1227 | @NonNull Server server, |
1234 | 1228 | @NonNull ExecutionMode executionMode, |
1235 | 1229 | @NonNull List<Supplier<Jooby>> provider) { |
1236 | | - runApp(args, server, null, executionMode, provider); |
1237 | | - } |
1238 | | - |
1239 | | - /** |
1240 | | - * Setup default environment, logging (logback or log4j2) and run application. |
1241 | | - * |
1242 | | - * @param args Application arguments. |
1243 | | - * @param server Server. |
1244 | | - * @param executionMode Default application execution mode. Can be overridden by application. |
1245 | | - * @param provider Application provider. |
1246 | | - */ |
1247 | | - private static void runApp( |
1248 | | - @NonNull String[] args, |
1249 | | - @NonNull Server server, |
1250 | | - @Nullable ServerOptions options, |
1251 | | - @NonNull ExecutionMode executionMode, |
1252 | | - @NonNull List<Supplier<Jooby>> provider) { |
1253 | | - |
1254 | 1230 | /* Dump command line as system properties. */ |
1255 | 1231 | parseArguments(args).forEach(System::setProperty); |
| 1232 | + ServerOptions appServerOptions = null; |
1256 | 1233 | var apps = new ArrayList<Jooby>(); |
1257 | 1234 | var targetServer = server.getLoggerOff().isEmpty() ? server : MutedServer.mute(server); |
1258 | 1235 | try { |
1259 | 1236 | for (var factory : provider) { |
1260 | 1237 | var app = createApp(server, executionMode, factory); |
1261 | 1238 | /* |
1262 | 1239 | When running a single app instance, there is no issue with server options. |
1263 | | - When multiple apps pick first on the provided order. |
| 1240 | + When multiple apps pick first in the provided order. |
1264 | 1241 | */ |
1265 | | - if (options == null) { |
1266 | | - options = ServerOptions.from(app.getConfig()).orElse(null); |
| 1242 | + if (appServerOptions == null) { |
| 1243 | + appServerOptions = ServerOptions.from(app.getConfig()).orElse(null); |
1267 | 1244 | } |
1268 | 1245 | apps.add(app); |
1269 | 1246 | } |
1270 | | - if (options != null) { |
1271 | | - server.setOptions(options); |
| 1247 | + // Override when there is something and server options were not set |
| 1248 | + if (server.getOptions().defaults && appServerOptions != null) { |
| 1249 | + server.setOptions(appServerOptions); |
1272 | 1250 | } |
1273 | 1251 | targetServer.start(apps.toArray(new Jooby[0])); |
1274 | 1252 | } catch (Throwable startupError) { |
|
0 commit comments