I have a WildFly 10 server in which about 12 deployments are installed, and the list of deployments may change periodically. The main problem is that when i'm restart the server, applications are trying to deploy simultaneously. However, most applications cannot start until some other deployments have been launched. In fact, they have a strict sequence to run. Thus, when the Wildfly server is restarted, part of the deployment will be started with an error and will not work. I came up with some hack:
- Stop the server process WildFly
- In standalone.xml, all deployments set to the disable status (via the cli command)
- Start the server WildFly
- Run the script:
export JAVA_HOME=/usr/java/jdk1.8.0_131
export WILDFLY_HOME=/opt/wildfly
PATH=$WILDFLY_HOME/bin:$PATH
jcli=$WILDFLY_HOME/bin/jboss-cli.sh
args="--connect --controller=`hostname`:9990"
modules=`$jcli $args --command="ls deployment -l" | sed 's/\(.*\)/deploy --name=\1/'`
if [ -z "${modules// /}" ]
then
echo "Nothing to start on this server `hostname`"
exit 0
fi
$jcli $args <<EOF
batch
$modules
run-batch --headers={allow-resource-service-restart=true}
EOF
At the same time, when I first run the script from 4 points, I get errors: ClassNotFoundException and NoClassDefFoundError. No deployments start. But if i'm run this script a second time - everything starts.
Actually the question is, how is it that the second time everything starts? Is there a way to make it easier, without errors, maybe there is an operation in the CLI that does all this “correctly” (generates a startup sequence or something like that)?