Wednesday, August 12, 2015

Managed Server Operations without NM

wls_ms_operations.sh

Usage: ./wls_ms_operations.sh {start|stop|restart} {SERVER-NAME}

#!/bin/bash
server_name=$2
export DOMAIN_LOG=/opt/admin/fmw/

stop() {
        echo "Stopping Managed Server(s)..." $server_name
        echo $SUDO_USER "gave stop command for $server_name at" `/bin/date` > $DOMAIN_LOG/shutdown_$server_name.log
        nohup /opt/admin/fmw/domains/myDomain/bin/stopManagedWebLogic.sh $server_name > $DOMAIN_LOG/shutdown_$server_name.log 2> /dev/null &
        echo "Follow the log @ /opt/admin/fmw/domains/myDomain/servers/${server_name}/logs/"

}

start() {

        echo "Starting Managed Server..." $server_name
        echo $SUDO_USER "gave start command for $server_name at" `/bin/date` > $DOMAIN_LOG/startup_$server_name.log
        nohup /opt/admin/fmw/domains/myDomain/bin/startManagedWebLogic.sh $server_name t3://localhost:7001 2> /dev/null &
        echo "Follow the log @ /opt/admin/fmw/domains/myDomain/servers/${server_name}/logs/"

        exit 1
}

restart() {
        echo "Stopping Managed Server(s)..." $server_name
        echo $SUDO_USER "gave stop command for $server_name at" `/bin/date` > $DOMAIN_LOG/shutdown_$server_name.log
        nohup /opt/admin/fmw/domains/myDomain/bin/stopManagedWebLogic.sh $server_name > $DOMAIN_LOG/shutdown_$server_name.log 2> /dev/null &
        echo "Follow the log @ /opt/admin/fmw/domains/myDomain/servers/${server_name}/logs/"
sleep 10
pid=$(ps auxwww | grep ${server_name}| grep Dweblogic | cut -c 10-15 | tr -d ' ')
if [[ ! -z "$pid" ]]
                then
                        `kill -9 ${pid}`
echo "Killed the process..."
fi
        
echo "Now Starting Managed Server..." $server_name
        echo $SUDO_USER "gave start command for $server_name at" `/bin/date` > $DOMAIN_LOG/startup_$server_name.log
        nohup /opt/admin/fmw/domains/myDomain/bin/startManagedWebLogic.sh $server_name t3://localhost:7001 2> /dev/null &
        echo "Follow the log @ /opt/admin/fmw/domains/myDomain/servers/${server_name}/logs/"
        exit 1

}

case "$1" in

        "start")
                start
                ;;
        "stop")
                stop
                ;;
       "restart")
                restart
                ;;
        *)
                echo $"Usage: $0 {start|stop|restart} {SERVER-NAME}"
                exit 1
                ;;

esac
exit

No comments:

Post a Comment