Skip to content

Instantly share code, notes, and snippets.

@ciis0
Last active February 21, 2023 19:35
Show Gist options
  • Save ciis0/b527b420b82605ef799dfd311992e3bf to your computer and use it in GitHub Desktop.
Save ciis0/b527b420b82605ef799dfd311992e3bf to your computer and use it in GitHub Desktop.
jboss restart with server-log rotate and waiting for jboss to be ready again
#!/usr/bin/env bash
set -ex
cd $(dirname $BASH_SOURCE)
log=standalone/log/server.log
log_new=${log}.$(date +%Y-%m-%d)
log_num=$(ls -d "$log_new"* | wc -l)
mv $log $log_new-$log_num
jboss-api()
{
req=$1
curl --anyauth -u admin:admin -fsS localhost:9990/management -d "$1" -H "Content-Type: application/json"
}
# shutdown returns too fast and would lead to false positives when checking whether jboss is back
# when suspended, jboss does not respond to 8080 anymore
jboss-api '{"address":[],"operation":"suspend"}'
jboss-api '{"address":[],"operation":"shutdown","restart":true}'
while ! curl -fsS localhost:8080 >/dev/null; do sleep 1; done; echo jboss up $(date)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment