Wrote this as I wanted any starts of my managed servers under WebLogic to wait until the Admin Server is finished launching.
It also doubles as great syntax bookmark for what core components to start on the WebLogic server and what the filenames are.
function weblogicStart() {
START_COMMAND="$1"
LOG_OUTPUT="$2"
"$START_COMMAND" > "$LOG_OUTPUT" 2>&1 &
}
function weblogicStart_ManagedServer() {
START_COMMAND="$1"
SERVER_NAME="$2"
ADMIN_SERVER_URL="$3"
LOG_OUTPUT="$4"
"$START_COMMAND" "$SERVER_NAME" "$ADMIN_SERVER_URL" > "$LOG_OUTPUT" 2>&1 &
}
function weblogicWait() {
SERVER_NAME="$1"
LOG_FILE="$2"
echo "Waiting until WebLogic $SERVER_NAME is finished starting up before continuing..."
( tail -f -n0 "$LOG_FILE" & ) | grep -q "<Server state changed to RUNNING.>"
echo "WebLogic $SERVER_NAME is Up!"
}
#Log Root for All Logs
LOG_ROOT="/home/oracle"
#Hack to remove any straggling domain backups that prevent changes from persisting on reboot
rm -Rf /home/oracle/Oracle/Middleware/Oracle_Home/user_projects/domains/base_domain/servers/domain_bak/*
#Defining core WebLogic Logs and Commands
WEBLOGIC_DOMAIN_ROOT="/home/oracle/Oracle/Middleware/Oracle_Home/user_projects/domains/base_domain"
WEBLOGIC_ADMINSERVER_LOG="$LOG_ROOT/weblogic.out"
WEBLOGIC_ADMINSERVER_URL="http://localhost:8080"
WEBLOGIC_ADMINSERVER_SERVERNAME="AdminServer"
WEBLOGIC_ADMINSERVER_START="$WEBLOGIC_DOMAIN_ROOT/startWebLogic.sh"
WEBLOGIC_MANAGEDSERVER_START="$WEBLOGIC_DOMAIN_ROOT/bin/startManagedWebLogic.sh"
WEBLOGIC_NODEMANAGER_LOG="$LOG_ROOT/nodemanager.out"
WEBLOGIC_NODEMANAGER_START="$WEBLOGIC_DOMAIN_ROOT/bin/startNodeManager.sh"
#Defining JVM1 WebLogic Server Names and Log Paths
WEBLOGIC_JVM1_LOG="$LOG_ROOT/JVM1.out"
WEBLOGIC_JVM1_SERVERNAME="JVM1"
#Begin Weblogic Commands
weblogicStart "$WEBLOGIC_NODEMANAGER_START" "$WEBLOGIC_NODEMANAGER_LOG"
weblogicStart "$WEBLOGIC_ADMINSERVER_START" "$WEBLOGIC_ADMINSERVER_LOG"
#Wait Until Admin Server is finished booting up
weblogicWait "$WEBLOGIC_ADMINSERVER_SERVERNAME" "$WEBLOGIC_ADMINSERVER_LOG"
#Start Admin Server
weblogicStart_ManagedServer "$WEBLOGIC_MANAGEDSERVER_START" "$WEBLOGIC_JVM1_SERVERNAME" "$WEBLOGIC_ADMINSERVER_URL" "$WEBLOGIC_JVM1_LOG"