Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Jboss EAP 6 CLI Script with commands that require reload

Tags:

I'm working on a cli script for JBoss EAP 6 (just a bunch of commands in a .bat file).

Now I'm running into issues with commands that rely on each other, where the former sets the server to a "reload-required" state.

For example:

  1. first command: remove default-datasource ExampleDS. Outcome: success, server in state "reload required"
  2. second command: remove h2-driver (required by default datasource). Outcome: failed, since server has not been restarted yet.

I've tried to place a reload command in between, but it seems as if the server is not completely up when the second command gets executed. Outcome still is failed, although if I try it a few seconds later, it works.

/subsystem=datasources/data-source=ExampleDS:remove
reload
/subsystem=datasources/jdbc-driver=h2:remove

Any suggestions how to make the CLI wait until JBoss is completely up again?

like image 885
Jbartmann Avatar asked Jul 13 '16 15:07

Jbartmann


1 Answers

Try batching those commands together and doing a reload after you run the batch. For example:

batch
/subsystem=datasources/data-source=ExampleDS:remove
/subsystem=datasources/jdbc-driver=h2:remove
:reload
run-batch

Another option is to run the server to start the server in admin-only mode while configuring it. You should need the reload command in that case, but if you do make sure you use :reload(admin-only=true) until you're done configuring the server.

%JBOSS_HOME%\bin\standalone.bat --admin-only
rem Wait until server is started, then execute the CLI commands
%JBOSS_HOME%\bin\jboss-cli.bat -c --commands="/subsystem=datasources/data-source=ExampleDS:remove,/subsystem=datasources/jdbc-driver=h2:remove"
like image 81
James R. Perkins Avatar answered Sep 28 '22 02:09

James R. Perkins