Package org.wildfly.glow
Class ExecUtil
java.lang.Object
org.wildfly.glow.ExecUtil
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voiddestroyProcess(Process process) Kill the process, if still alive, kill it forciblystatic booleanexec(File directory, String command, GlowMessageWriter writer, String... args) Execute the specified command from within the specified directory.The method allows specifying an output filter that processes the command output.static booleanexec(String command, GlowMessageWriter writer, String... args) Execute the specified command from within the current directory.static booleanexecSilentWithTimeout(Duration timeout, String command, GlowMessageWriter writer, String... args) Execute silently the specified command until the given timeout from within the current directory.static booleanexecWithTimeout(File directory, Duration timeout, String command, GlowMessageWriter writer, String... args) Execute the specified command until the given timeout from within the specified directory.The method allows specifying an output filter that processes the command output.static StringresolveImageBinary(GlowMessageWriter writer) Resolves which image binary to use.Firstdockeris tried.static ProcessstartProcess(File directory, String command, String... args) Start a process executing given command with arguments within the specified directory.
-
Constructor Details
-
ExecUtil
public ExecUtil()
-
-
Method Details
-
exec
Execute the specified command from within the current directory.- Parameters:
command- The commandwriter-args- The command arguments- Returns:
- true if commands where executed successfully
-
execSilentWithTimeout
public static boolean execSilentWithTimeout(Duration timeout, String command, GlowMessageWriter writer, String... args) Execute silently the specified command until the given timeout from within the current directory.- Parameters:
timeout- The timeoutcommand- The commandwriter-args- The command arguments- Returns:
- true if commands where executed successfully
-
exec
public static boolean exec(File directory, String command, GlowMessageWriter writer, String... args) Execute the specified command from within the specified directory.The method allows specifying an output filter that processes the command output.- Parameters:
directory- The directorycommand- The commandwriter-args- The command arguments- Returns:
- true if commands where executed successfully
-
execWithTimeout
public static boolean execWithTimeout(File directory, Duration timeout, String command, GlowMessageWriter writer, String... args) Execute the specified command until the given timeout from within the specified directory.The method allows specifying an output filter that processes the command output.- Parameters:
directory- The directorytimeout- The timeoutcommand- The commandwriter-args- The command arguments- Returns:
- true if commands where executed successfully
-
startProcess
Start a process executing given command with arguments within the specified directory.- Parameters:
directory- The directorycommand- The commandargs- The command arguments- Returns:
- the process
-
destroyProcess
Kill the process, if still alive, kill it forcibly- Parameters:
process- the process to kill
-
resolveImageBinary
Resolves which image binary to use.Firstdockeris tried. If docker does not exist, thenpodmanis tried. If podman does not existnullis returned.- Parameters:
writer-- Returns:
- the resolved binary, or
nullif docker or podman was not found
-