0

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).

Adrodoc
  • 673
  • 10
  • 19

2 Answers2

2

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 :)

ehsavoie
  • 3,126
  • 1
  • 16
  • 14
  • 1
    I'll quote myself: 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. – Adrodoc Mar 29 '19 at 15:33
2

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 
Erhard Siegl
  • 557
  • 2
  • 8
  • That is quite a workaround, unfortunately I am using both Linux and Windows systems, but a similar workaround is probably possible on windows too (although I don't know enough about windows shell to be certain), so I might use this as a fallback. – Adrodoc Apr 10 '19 at 16:12