Skip to content

Instantly share code, notes, and snippets.

@nyxcalamity
Last active November 14, 2017 06:24
Show Gist options
  • Save nyxcalamity/10667381 to your computer and use it in GitHub Desktop.
Save nyxcalamity/10667381 to your computer and use it in GitHub Desktop.
Utility scripts to clean up glassfish domain folders to avoid permgen exception
#!/bin/bash
#Cleans up glassfish domain folders so that the maven deployment with cargo doesn't hang.
#---------------------------------------------------------------------------------------------------
# CUSTOMIZATION SECTION START
#---------------------------------------------------------------------------------------------------
export GF_DIR=/home/nyxcalamity/ws/appservers/glassfish
#---------------------------------------------------------------------------------------------------
# CUSTOMIZATION SECTION END
#---------------------------------------------------------------------------------------------------
export OK="$(tput setaf 2) DONE$(tput sgr0)"
export DOMAIN_DIR=$GF_DIR/glassfish/domains/
for d in $DOMAIN_DIR/*; do
echo -n "Cleaning up: $d"
rm -rf $d/applications/*
rm -rf $d/generated/*
rm -rf $d/osgi-cache/*
echo $OK
done
echo "$(tput setaf 4)Glassfish cleanup completed.$(tput sgr0)"
#!/bin/bash
#Performs a glassfish server cleanup in order for it not to suspend.
#---------------------------------------------------------------------------------------------------
# CUSTOMIZATION SECTION START
#---------------------------------------------------------------------------------------------------
GF_DIR=appservers/glassfish
APP=crx-app
#---------------------------------------------------------------------------------------------------
# CUSTOMIZATION SECTION END
#---------------------------------------------------------------------------------------------------
OK="$(tput setaf 2) DONE$(tput sgr0)"
#---------------------------------------------------------------------------------------------------
#0:Initializing misc variables
HOST=$1
USER=$2
GF_DOMAIN=$3
GF_ADMIN_PORT=$4
GF_HOME=/home/$USER/$GF_DIR
GF_DOMAIN_DIR=$GF_HOME/glassfish/domains/$GF_DOMAIN
GF_ASADMIN="$GF_HOME/bin/asadmin --port=$GF_ADMIN_PORT"
CMD="ssh $USER@$HOST"
#1:undeploy the app
echo -n "Undeploying the app:"
undeploy="$($CMD $GF_ASADMIN undeploy $APP)"
echo $OK
#2:stop domain
echo -n "Stopping the domain:"
stop="$($CMD $GF_ASADMIN stop-domain $GF_DOMAIN)"
echo $OK
#3:clean generated and etc
echo -n "Cleaning domain dirs:"
appremove="$($CMD rm -rf $GF_DOMAIN_DIR/applications/*)"
genremove="$($CMD rm -rf $GF_DOMAIN_DIR/generated/*)"
osgiremove="$($CMD rm -rf $GF_DOMAIN_DIR/osgi-cache/*)"
echo $OK
#4:starting domain
echo -n "Starting the domain:"
stop="$($CMD $GF_ASADMIN start-domain $GF_DOMAIN)"
echo $OK
echo "$(tput setaf 4)Glassfish cleanup completed.$(tput sgr0)"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment