diff --git a/nucleus/admin/launcher/src/main/java/com/sun/enterprise/admin/launcher/GFLauncherInfo.java b/nucleus/admin/launcher/src/main/java/com/sun/enterprise/admin/launcher/GFLauncherInfo.java index c8f08547284..e06fad739eb 100644 --- a/nucleus/admin/launcher/src/main/java/com/sun/enterprise/admin/launcher/GFLauncherInfo.java +++ b/nucleus/admin/launcher/src/main/java/com/sun/enterprise/admin/launcher/GFLauncherInfo.java @@ -37,7 +37,7 @@ * only if the new code is made subject to such option by the copyright * holder. */ -// Portions Copyright [2016-2018] [Payara Foundation] +// Portions Copyright [2016-2023] [Payara Foundation] package com.sun.enterprise.admin.launcher; @@ -149,6 +149,12 @@ public void setUpgrade(boolean b) { upgrade = b; } + /** + * Starts the server and after bootstrapping immediately stop + * @param b + */ + public void setWarmup(boolean b) { warmup = b; } + public void setDomainRootDir(File f) { domainRootDir = f; } @@ -205,6 +211,14 @@ public boolean isUpgrade() { return upgrade; } + /** + * + * @return true if the warmup is on. + */ + public boolean isWarmup() { + return warmup; + } + /** * * @return The domain name @@ -337,6 +351,7 @@ else if(isInstance()) { map.put("-debug", Boolean.toString(debug)); map.put("-instancename", instanceName); map.put("-upgrade", Boolean.toString(upgrade)); + map.put("-warmup", Boolean.toString(warmup)); map.put("-read-stdin", "true"); //always make the server read the stdin for master password, at least. if(respawnInfo != null) { @@ -458,6 +473,13 @@ else if(tsb.isFalse()) upgrade = true; else if(tsb.isFalse()) upgrade = false; + + tsb = getBoolean("warmup"); + if (tsb.isTrue()) { + warmup = true; + } else if (tsb.isFalse()) { + warmup = false; + } } private void finalSetup() throws GFLauncherException { @@ -607,6 +629,7 @@ private String getValueIgnoreCommandDelimiter(String key) { private boolean watchdog = false; private boolean debug = false; private boolean upgrade = false; + private boolean warmup = false; File installDir; private File domainParentDir; private File domainRootDir; diff --git a/nucleus/admin/server-mgmt/src/main/java/com/sun/enterprise/admin/servermgmt/cli/LocalStrings.properties b/nucleus/admin/server-mgmt/src/main/java/com/sun/enterprise/admin/servermgmt/cli/LocalStrings.properties index 3346bbcef91..b09de76d88d 100644 --- a/nucleus/admin/server-mgmt/src/main/java/com/sun/enterprise/admin/servermgmt/cli/LocalStrings.properties +++ b/nucleus/admin/server-mgmt/src/main/java/com/sun/enterprise/admin/servermgmt/cli/LocalStrings.properties @@ -37,7 +37,7 @@ # only if the new code is made subject to such option by the copyright # holder. # -# Portions Copyright [2016-2021] [Payara Foundation and/or its affiliates] +# Portions Copyright [2016-2023] [Payara Foundation and/or its affiliates] ## list-domains ## domain1 running @@ -194,6 +194,7 @@ ServerStart.SuccessMessage=Successfully started the {0}: {1}\n{0} Location: {2}\ ServerStart.DebuggerMessage=Debugging is enabled. The debugging port is: {0} ServerStart.DebuggerSuspendedMessage=Debugging is enabled and the server is suspended. \ Please attach to the debugging port at: {0} +ServerStart.SuccessWithWarmupEnabled=The server stops because warmup option was set to true. \nYou can reuse configuration because Server finishes after bootstrapping. DomainLocation=Started domain: {0}\nDomain location: {1}\nLog file: {2} DomainAdminPort=Admin port for the domain: {0} DomainDebugPort=Debug port for the domain: {0} diff --git a/nucleus/admin/server-mgmt/src/main/java/com/sun/enterprise/admin/servermgmt/cli/StartDomainCommand.java b/nucleus/admin/server-mgmt/src/main/java/com/sun/enterprise/admin/servermgmt/cli/StartDomainCommand.java index 061a894c614..c984bb8574b 100644 --- a/nucleus/admin/server-mgmt/src/main/java/com/sun/enterprise/admin/servermgmt/cli/StartDomainCommand.java +++ b/nucleus/admin/server-mgmt/src/main/java/com/sun/enterprise/admin/servermgmt/cli/StartDomainCommand.java @@ -101,6 +101,9 @@ public class StartDomainCommand extends LocalDomainCommand implements StartServe @Param(defaultValue = "600", optional = true) protected int timeout; + @Param(optional = true, defaultValue = "false") + private boolean warmup; + @Inject ServerEnvironment senv; @@ -181,6 +184,11 @@ protected int executeCommand() throws CommandException { doAdminPasswordCheck(); + if (warmup) { + info.setWarmup(warmup); + helper.setWarmup(warmup); + } + // launch returns very quickly if verbose is not set // if verbose is set then it returns after the domain dies launcher.launch(); @@ -247,6 +255,7 @@ public void createLauncher() info.setDebug(debug); info.setUpgrade(upgrade); info.setWatchdog(watchdog); + info.setWarmup(warmup); info.setDropInterruptedCommands(drop_interrupted_commands); info.setPrebootCommandsFile(preBootCommand); info.setpostbootCommandsFile(postBootCommand); @@ -270,6 +279,7 @@ private String[] respawnArgs() { args.add("--verbose=" + verbose); args.add("--watchdog=" + watchdog); args.add("--debug=" + debug); + args.add("--warmup=" + warmup); args.add("--domaindir"); args.add(getDomainsDir().toString()); if (ok(getDomainName())) diff --git a/nucleus/admin/server-mgmt/src/main/java/com/sun/enterprise/admin/servermgmt/cli/StartServerHelper.java b/nucleus/admin/server-mgmt/src/main/java/com/sun/enterprise/admin/servermgmt/cli/StartServerHelper.java index 04539aea8f2..5cc9a178ff9 100644 --- a/nucleus/admin/server-mgmt/src/main/java/com/sun/enterprise/admin/servermgmt/cli/StartServerHelper.java +++ b/nucleus/admin/server-mgmt/src/main/java/com/sun/enterprise/admin/servermgmt/cli/StartServerHelper.java @@ -94,6 +94,8 @@ public class StartServerHelper { private final int debugPort; private final boolean isDebugSuspend; // only set when actively trouble-shooting or investigating... + + private boolean isWarmup = false; private static final boolean DEBUG_MESSAGES_ON = false; private static final LocalStringsImpl STRINGS = new LocalStringsImpl(StartServerHelper.class); @@ -273,6 +275,9 @@ public void report() { if (debugPort >= 0) { logger.info(STRINGS.get("ServerStart.DebuggerMessage", "" + debugPort)); } + if (isWarmup) { + logger.info(STRINGS.get("ServerStart.SuccessWithWarmupEnabled")); + } } /** @@ -424,6 +429,14 @@ private static void debugMessage(String s) { CLIUtil.writeCommandToDebugLog("restart-debug", env, new String[]{"DEBUG MESSAGE FROM RESTART JVM", s}, 99999); } } + + public void setWarmup(boolean warmup) { + this.isWarmup = warmup; + } + + public boolean getWarmup() { + return isWarmup; + } /** * bnevins diff --git a/nucleus/admin/server-mgmt/src/main/manpages/com/sun/enterprise/admin/servermgmt/cli/start-domain.1 b/nucleus/admin/server-mgmt/src/main/manpages/com/sun/enterprise/admin/servermgmt/cli/start-domain.1 index d4b7283dabc..78d9919b2be 100644 --- a/nucleus/admin/server-mgmt/src/main/manpages/com/sun/enterprise/admin/servermgmt/cli/start-domain.1 +++ b/nucleus/admin/server-mgmt/src/main/manpages/com/sun/enterprise/admin/servermgmt/cli/start-domain.1 @@ -8,7 +8,7 @@ SYNOPSIS [--debug={true|false}] [--domaindir domain-dir] [--dry-run={true|false}] [--upgrade={true|false}] [--verbose={true|false}] [--watchdog={true|false}] - [--timeout timeout] [domain-name] + [--timeout timeout] [--warmup={true|false}] [domain-name] DESCRIPTION The start-domain subcommand starts the domain administration server @@ -152,6 +152,9 @@ OPTIONS Specifies the amount of time in seconds the command will run for before timing out. Default is 600 seconds. + --warmup + Exit the server immediately after configuration is done. By default this is set as false. + OPERANDS domain-name The unique name of the domain you want to start. diff --git a/nucleus/core/bootstrap/src/main/java/com/sun/enterprise/glassfish/bootstrap/LogFacade.java b/nucleus/core/bootstrap/src/main/java/com/sun/enterprise/glassfish/bootstrap/LogFacade.java index 43530f33d25..2a9687785b7 100644 --- a/nucleus/core/bootstrap/src/main/java/com/sun/enterprise/glassfish/bootstrap/LogFacade.java +++ b/nucleus/core/bootstrap/src/main/java/com/sun/enterprise/glassfish/bootstrap/LogFacade.java @@ -37,7 +37,7 @@ * only if the new code is made subject to such option by the copyright * holder. */ -// Portions Copyright [2021] [Payara Foundation and/or its affiliates] +// Portions Copyright [2021-2023] [Payara Foundation and/or its affiliates] package com.sun.enterprise.glassfish.bootstrap; @@ -265,6 +265,11 @@ public static void log(Logger logger, Level level, String messageId, message = "Got an unexpected exception.", level = "WARNING") public static final String CAUGHT_EXCEPTION = "NCLS-BOOTSTRAP-00039"; + + @LogMessageInfo( + message = "The option warmup was set to true, stopping the server.", + level = "WARNING") + public static final String WARMUP_OPTION_AS_TRUE = "NCLS-BOOTSTRAP-00040"; } diff --git a/nucleus/core/bootstrap/src/main/java/com/sun/enterprise/glassfish/bootstrap/osgi/EmbeddedOSGiGlassFishImpl.java b/nucleus/core/bootstrap/src/main/java/com/sun/enterprise/glassfish/bootstrap/osgi/EmbeddedOSGiGlassFishImpl.java index dda545eab5b..0009f617332 100644 --- a/nucleus/core/bootstrap/src/main/java/com/sun/enterprise/glassfish/bootstrap/osgi/EmbeddedOSGiGlassFishImpl.java +++ b/nucleus/core/bootstrap/src/main/java/com/sun/enterprise/glassfish/bootstrap/osgi/EmbeddedOSGiGlassFishImpl.java @@ -37,7 +37,7 @@ * only if the new code is made subject to such option by the copyright * holder. */ -// Portions Copyright [2018] Payara Foundation and/or affiliates +// Portions Copyright [2018-2023] Payara Foundation and/or affiliates package com.sun.enterprise.glassfish.bootstrap.osgi; @@ -74,6 +74,11 @@ public EmbeddedOSGiGlassFishImpl(GlassFish decoratedGf, BundleContext bundleCont public void start() throws GlassFishException { super.start(); registerService(); + if (bundleContext.getProperty("-warmup") != null && bundleContext.getProperty("-warmup").equals("true")) { + logger.log(Level.WARNING, LogFacade.WARMUP_OPTION_AS_TRUE); + stop(); + System.exit(0); + } } @Override