Class ServerProcess
java.lang.Object
org.wildfly.qa.tooling.processexecution.ServerProcess
- Direct Known Subclasses:
BootableJarProcess, DomainServerProcess
Abstraction over server process - starting the process, executing a runnable in the right moment and destroying it.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceFunctional interface encapsulating method which code runs upon satisfaction of a condition -
Constructor Summary
ConstructorsModifierConstructorDescriptionServerProcess(org.apache.commons.exec.CommandLine startScript) Create a new instance of server process.ServerProcess(org.apache.commons.exec.CommandLine startScript, long timeout, TimeUnit timeUnit) Create a new instance of server process.protectedServerProcess(org.apache.commons.exec.CommandLine startScript, long timeout, TimeUnit timeUnit, org.wildfly.extras.creaper.core.online.OnlineOptions onlineOptions) Create a new instance of server process. -
Method Summary
Modifier and TypeMethodDescriptionvoidrunAfterDeploymentCompletedAndDestroyProcess(String deploymentName, ServerProcess.ServerRunnable runnable) Start a server and run a runnable after the deployment was deployed.voidStart a server and run a runnable after the server started.voidStart a server and run a runnable after the client connects.
-
Constructor Details
-
ServerProcess
public ServerProcess(org.apache.commons.exec.CommandLine startScript) Create a new instance of server process. Instantiating won't create the server process. Timeout is read from system propertyProcessExecutionProperties.SERVER_PROCESS_TIMEOUT_MINUTES(default 5 minutes). If you wish to have other timeout useServerProcess(CommandLine, long, TimeUnit).- Parameters:
startScript- start script command line
-
ServerProcess
public ServerProcess(org.apache.commons.exec.CommandLine startScript, long timeout, TimeUnit timeUnit) Create a new instance of server process. Instantiating won't create the server process.- Parameters:
startScript- start script command linetimeout- the maximum time to waittimeUnit- the time unit of the timeout parameter
-
ServerProcess
protected ServerProcess(org.apache.commons.exec.CommandLine startScript, long timeout, TimeUnit timeUnit, org.wildfly.extras.creaper.core.online.OnlineOptions onlineOptions) Create a new instance of server process. Instantiating won't create the server process.- Parameters:
startScript- start script command linetimeout- the maximum time to waittimeUnit- the time unit of the timeout parameteronlineOptions- options for server settings
-
-
Method Details
-
runAfterServerStartedAndDestroyProcess
public void runAfterServerStartedAndDestroyProcess(ServerProcess.ServerRunnable runnable) throws IOException, InterruptedException Start a server and run a runnable after the server started. Completed start is detected by "started in" line in the server log. e.g. 12:03:45,777 INFO [org.jboss.as] (Controller Boot Thread) WFLYSRV0025: WildFly 41.0.1.Final (WildFly Core 23.0.3.Final) started in 2315ms - Started 317 of 556 services (343 services are lazy, passive or on-demand) Please be aware that the timeout is set in constructor- Parameters:
runnable- a runnable which should be run when server started. Server will be destroyed after runnable completed.- Throws:
IOExceptionInterruptedException
-
runAfterDeploymentCompletedAndDestroyProcess
public void runAfterDeploymentCompletedAndDestroyProcess(String deploymentName, ServerProcess.ServerRunnable runnable) throws IOException, InterruptedException Start a server and run a runnable after the deployment was deployed. Completed deployment is detected by'Deployed "<name>"' in the log. e.g. 12:07:31,023 INFO [org.jboss.as.server] (management-handler-thread - 1) WFLYSRV0010: Deployed "fooqixbar" (runtime-name : "qux")Please be aware that the timeout is set in constructor- Parameters:
deploymentName- name of deployment which wil trigger runnable run.runnable- a runnable which should be run when server started. Server will be destroyed after runnable completed.- Throws:
IOExceptionInterruptedException
-
runWhenClientConnectsAndDestroyProcess
public void runWhenClientConnectsAndDestroyProcess(ServerProcess.ServerRunnable runnable) throws IOException, InterruptedException Start a server and run a runnable after the client connects. The launched process and its children are destroyed after the runnable completes, including when it throws. The runnable does not need to shut down the server itself.- Parameters:
runnable- a runnable which should be run when server started. Server will be destroyed after runnable completed.- Throws:
IOExceptionInterruptedException
-