Creating your own Run Engine commands
If the predefined Run Engine commands do not satisfy your requirements, you can create your own commands.
Note: Using Run Engine commands is one approach by which HCL uses to implement environment
configurations. Based on your scenario, you might want to implement a custom solution to modify
environment parameters and container configurations that might better suit your needs.
About this task
- If you want to use Java or Groovy classes to change configurations, you can define your class to
inherit from the
BaseCommand
class (in Docker_container/SETUP/lib/engine-command.jar). - If you want to use other scripting languages, such as Python, you can define your class to
inherit from
ScriptCommand
.
Procedure
-
Create an empty Java or Groovy project and create three child directories
(src, META-INF, scripts).
- project
- src
- META-INF
- scriptsNote: The scripts directory is only required when using
ScriptCommand
.
- project
- Add engine-command.jar as a dependency.
-
Create a class that inherits from
BaseCommand
orScriptCommand
based on the type of code or script that you want to deploy. Within the class, create arunCmd
method to define your actions.- Extend the
BaseCommand
if you want to implement logic by using Java or Groovy code. - Extend the
ScriptCommand
if you want to implement logic by using other scripting languages such as Python.
For example,- The following class
WCCommand
inherits fromScriptCommand
, and the command outputs a string.class WCCommand extends ScriptCommand{ void runCmd(String[] args) { println "wc-sample" } }
- The following class
WCCommand
inherits fromBaseComand
.import com.ibm.commerce.engine.cmd.BaseCommand class WCCommmand extends BaseCommand { public void runCmd(String[] args) { // ADD logic here to modify environment parameters and container configurations } }
- Extend the
- Save the class in the src directory.
-
If needed, create scripts in the script directory to complete a
configuration.
For example, the following Python script (createJMSQueue.py) uses WebSphere Application Server wsadmin scripting commands to configure IBM MQ JMS resources.
queueName = sys.argv[1] queueManager = sys.argv[2] AdminTask.createWMQQueue('server1(cells/localhost/nodes/localhost/servers/server1|server.xml)', '[-name '+ jndiName +' -jndiName '+jndiName+' -queueName '+ queueName + ' -qmgr '+queueManager+' -description JMSQueue ]') print ("Create JMS queues successfully!") AdminConfig.save()
- For more information about wsadmin commands for IBM MQ, see Configuring JMS resources using wsadmin scripting commands.
- For general information about wsadmin commands, see Scripting the application serving environment
-
Create a properties file and save to the META-INF directory.
Name the file as the Run Engine command name that you want to use.For example, if you want to use a Run Engine command such as
Then create a properties file that is namedrun create-jms-queues
create-jms-queues.properties
. - In the properties file, specify a main.class name-value pair to specify the class that you created. Also specify a main.script name-value pair if you created a script in step 5.
- Build and package the /src and /META-INF directories into a jar file.
-
Create or update a Dockerfile to include and use your custom Run Engine command.
- Ensure that you copy your jar file to the /SETUP/lib/ path in the Docker container.
- Ensure that you copy your scripts to the /SETUP/scripts/ path in the Docker container.
For example,FROM <dockerhost>/commerce/ts-app:latest COPY new.jar /SETUP/lib COPY scripts/ /SETUP/scripts RUN run create-jms-queues inbound mq FVT