Adrodoc
Adrodoc

Reputation: 773

WildFly CLI run script against embedded server

I have some scripts that I run using jboss-cli -c --controller=... --file=myscript.cli. The -c and --controller options are great, because my script does not know which server it should be run against and can be reused for multiple servers.

I now want to use the offline-cli feature to avoid port conflicts and prevent servers from beeing reachable through the network while they are beeing set up. My issue is now that in order to start an embedded server I have to use the CLI-command embed-server, but I don't want to add that command to my scripts, because the scripts are not supposed to know the name of the server config xml file.

Unfortunately I can't use both --command="embed-server --server-config=my-standalone.xml" and --file=myscript.cli at the same time, because the CLI complains with:

Only one of '--file', '--commands' or '--command' can appear as the argument at a time.

Another thing I tried was: --commands="embed-server --server-config=my-standalone.xml,run-batch --file=\"myscript.cli\" but this does not work either, because my scripts contain some if-else logic, for instance:

if (outcome == success) of /subsystem=iiop-openjdk:read-resource()
  /subsystem=iiop-openjdk:remove()
end-if

And unfortunately conditional logic is not supported in batch mode (see https://bugzilla.redhat.com/show_bug.cgi?id=1083176).

Upvotes: 1

Views: 4174

Answers (3)

maroswal
maroswal

Reputation: 96

I know old question but I stumbled across this question while searching the same problem and found a possible solution in the official enable-elytron-se17.cli script (part of JBoss EAP 7.4.x).

# By default, standalone.xml is updated.
# Run it from JBOSS_HOME as:
# bin/jboss-cli.sh --file=docs/examples/enable-elytron-se17.cli [-Dconfig=<standalone-full.xml|standalone-ha.xml|standalone-full-ha.xml>]

embed-server --server-config=${config:standalone.xml}

Upvotes: 0

Erhard Siegl
Erhard Siegl

Reputation: 577

If you are using a Unix system you may try something like this:

(echo embed-server --std-out=echo  --server-config=my-standalone.xml; cat myscript.cli) | jboss-cli.sh 

Upvotes: 2

ehsavoie
ehsavoie

Reputation: 3527

the simple way is to start your embedded server in your script :

embed-server --std-out=echo  --server-config=standalone-full.xml
/subsystem=messaging-activemq/server=default/jms-queue=inQueue:add(durable=true, entries=["/queue/inQueue","java:jboss/exported/queue/inQueue"])
/subsystem=messaging-activemq/server=default/jms-queue=outQueue:add(durable=true, entries=["/queue/outQueue","java:jboss/exported/queue/outQueue"])
quit

Don't forget to quit at the end of your cli script :)

Upvotes: 2

Related Questions