Created
June 23, 2023 00:58
-
-
Save fercomunello/a9a10eed3438c53ac0ec87154160972a to your computer and use it in GitHub Desktop.
Create a sandbox dev/test environment for WildFly Application Server
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# => Run configuration script via ./jboss-cli.sh | |
# Start the server in admin-only mode | |
embed-server --std-out=echo | |
# Show runtime info | |
version | |
batch | |
# JSP Tuning | |
/subsystem=undertow/servlet-container=default/setting=jsp:write-attribute(name=optimize-scriptlets,value=true) | |
/subsystem=undertow/servlet-container=default/setting=jsp:write-attribute(name=generate-strings-as-char-arrays,value=true) | |
/subsystem=undertow/servlet-container=default/setting=jsp:write-attribute(name=trim-spaces,value=true) | |
run-batch | |
# Stop the embedded server | |
stop-embedded-server |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
set -e | |
cd $(dirname $0) | |
export $(xargs < server.properties) | |
clear_tmp_folder() { | |
echo "=> Clear standalone/tmp folder" | |
rm -Rf server/standalone/tmp/* | |
} | |
clear_xml_history() { | |
echo "=> Clear standalone_xml_history/* folder" | |
rm -Rf server/standalone/configuration/standalone_xml_history/* | |
} | |
rm_non_unix_scripts() { | |
echo "" | |
echo "=> Remove non-unix scripts from bin/" | |
cd server/bin | |
rm standalone.bat standalone.ps1 | |
rm standalone.conf.bat standalone.conf.ps1 | |
rm jboss-cli.bat jboss-cli.ps1 | |
rm common.bat common.ps1 | |
rm elytron-tool.bat elytron-tool.ps1 | |
rm add-user.bat add-user.ps1 | |
rm jdr.bat jdr.ps1 | |
cd - > /dev/null | |
} | |
reset=false | |
deploy=false | |
debug_port=8787 | |
while [ "$#" -gt 0 ] | |
do | |
case "$1" in | |
-r|--reset) | |
reset=true | |
;; | |
-d|--deploy) | |
deploy=true | |
;; | |
--debug) | |
if [[ $2 =~ [1-9] ]]; then | |
debug_port = $2 | |
fi | |
shift | |
;; | |
*) | |
echo "Usage: ./run.sh [args...]" | |
echo "where args include:" | |
echo " -r, --reset: Reset the sandbox environment and provision a new WildFly instance." | |
echo " -d, --deploy: Build and deploy the .war artifacts on WildFly." | |
echo " --debug: Set the remote debug port. Default port is 8787." | |
exit 0 | |
esac | |
shift | |
done | |
if test ${reset} = true; then | |
rm -Rf server/ | |
fi | |
if [ -d "server" ]; then | |
clear_xml_history | |
clear_tmp_folder | |
else | |
mkdir tmp/ && cd tmp/ | |
echo "" | |
echo "=> Download and unzip WildFly Galleon packages" | |
echo "" | |
curl -L -O https://github.com/wildfly/galleon/releases/download/$WILDFLY_GALLEON_VERSION/galleon-$WILDFLY_GALLEON_VERSION.zip | |
unzip galleon-$WILDFLY_GALLEON_VERSION.zip | |
echo "" | |
echo "=> Provision a custom WildFly instance" | |
echo "" | |
./galleon-$WILDFLY_GALLEON_VERSION/bin/galleon.sh install wildfly:current#$WILDFLY_VERSION \ | |
--dir=../server --config=standalone/$WILDFLY_CONFIG --default-configs=standalone/$WILDFLY_CONFIG \ | |
--verbose --layers=$WILDFLY_LAYERS,$MIDDLEWARE_LAYERS,$JAKARTA_EE_LAYERS,$MICROPROFILE_LAYERS | |
cd .. | |
rm -Rf tmp/ | |
rm_non_unix_scripts | |
cd server/bin || exit 1 | |
echo "" | |
echo "=> Create a management user for WildFly: admin|redhat" | |
echo "" | |
./add-user.sh admin redhat --silent | |
cd - > /dev/null | |
clear_xml_history | |
clear_tmp_folder | |
fi | |
echo "" | |
echo "=> Remove old deployments" | |
rm -Rf server/standalone/deployments/*.war.failed | |
rm -Rf server/standalone/deployments/*.war.deployed | |
rm -Rf server/standalone/deployments/*.war | |
if test ${deploy} = true; then | |
echo "=> Build .war artifacts" | |
cd .. | |
mvn -T 1C clean package -DskipTests | |
cd - > /dev/null | |
echo "=> Copy .war files to deployments folder" | |
#cp -v ../app1/target/*.war server/standalone/deployments/ || exit 1 | |
#cp -v ../app2/target/*.war server/standalone/deployments/ || exit 1 | |
#cp -v ../app3/target/*.war server/standalone/deployments/ || exit 1 | |
fi | |
cd server/bin || exit 1 | |
echo "" | |
echo "=> Set JAVA_OPTS local environment variable" | |
echo "=> Set JVM parameters" | |
echo "=> Set remote debugging on port ${debug_port}" | |
echo "" | |
export JAVA_OPTS="-Xms512M -Xmx4096M -XX:MetaspaceSize=96M -XX:MaxMetaspaceSize=256m -Djava.net.preferIPv4Stack=true" | |
export JAVA_OPTS="$JAVA_OPTS -Djboss.modules.system.pkgs=org.jboss.byteman -Djava.awt.headless=false" | |
export JAVA_OPTS="$JAVA_OPTS -agentlib:jdwp=transport=dt_socket,address=${debug_port},server=y,suspend=n" | |
./standalone.sh -c $WILDFLY_CONFIG |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# With Galleon Layers, all the configurations of subsytems are custom - meaning that we are not required to use | |
# standalone-ha.xml or standalone-full-ha.xml to form a cluster or for embedded caching / messaging system. | |
# On Galleon we just add the layers that our app needs and we're good to go! | |
WILDFLY_CONFIG="standalone.xml" | |
WILDFLY_VERSION="27.0.1.Final" | |
WILDFLY_GALLEON_VERSION="5.1.0.Final" | |
WILDFLY_LAYERS="core-server,datasources,core-tools,undertow-https,discovery,web-console,jdr" | |
MIDDLEWARE_LAYERS="web-clustering,messaging-activemq,embedded-activemq" | |
JAKARTA_EE_LAYERS="jaxrs,cdi,jsf,jsonb,jsonp,bean-validation,mail" | |
MICROPROFILE_LAYERS="microprofile-platform,microprofile-reactive-messaging |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment