Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fish-7158: adding warmup option to start domain #6451

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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);
Expand All @@ -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()))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -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"));
}
}

/**
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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";

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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
Expand Down