Skip to content

Instantly share code, notes, and snippets.

@mtcoffee
Created September 12, 2016 15:58
Show Gist options
  • Save mtcoffee/4ac087b629cdca457ce75f2221b24531 to your computer and use it in GitHub Desktop.
Save mtcoffee/4ac087b629cdca457ce75f2221b24531 to your computer and use it in GitHub Desktop.
- description: |-
Find all domains within a PS_CFG_HOME and restart selected servers/clear cache:
*weblogic cache
*appserver cache
*process scheduler cache
executionEnabled: true
group: BasicTasks
id: ed3f817e-0e46-48fc-b609-1a4387ee99bd
loglevel: INFO
name: 'Stop,Start,Restart servers with cache clear '
nodefilters:
dispatch:
excludePrecedence: true
keepgoing: false
rankOrder: ascending
threadcount: 1
filter: 'name: rundeck.local'
nodesSelectedByDefault: true
options:
- description: Optionally you can tell the job to run a script in your environment prior. Useful if you need to switch between PS_CFG_HOME's
name: env
value: NotRequired
- enforced: true
name: StartOrStop
required: true
values:
- restart
- start
- stop
- description: Include Web Servers?
enforced: true
name: includeweb
required: true
value: 'no'
values:
- 'no'
- 'yes'
- description: Include App server?
enforced: true
name: includeapp
required: true
value: 'no'
values:
- 'no'
- 'yes'
- description: Include Process Scheduler?
enforced: true
name: includeprcs
required: true
value: 'no'
values:
- 'no'
- 'yes'
scheduleEnabled: true
sequence:
commands:
- description: ScriptToRunJob
script: |-
#/bin/bash
env=@option.env@
#set option environment script
if [ "$env" == "NotRequired" ]; then echo "no environment script specified, skipping";
else echo "environment script specified as '$env'";
. $env
fi
#Check if variables are set and point to valid paths
PATHSTOCHECK=(PS_HOME PS_CFG_HOME)
for i in ${PATHSTOCHECK[*]}; do
if [ -n "${!i}" ] && [ -d "${!i}" ]; then
echo "$i path ${!i} does exist"
else
echo "########################################"
echo "$i path ${!i} does not exist or variable is not set This needs to be corrected first."; exit 1
fi
done;
#Find the tools version for the PS_HOME
echo "PeopleToolsVersion"
grep -i "productversion" "$PS_HOME/peopletools.properties"
echo ""
#Find all domains for the PS_CFG_HOME
echo "###########################################################"
echo "THE FOLLOWING DOMAINS HAVE BEEN DISCOVERED FOR THE PS_CFG_HOME" $PS_CFG_HOME
#Find each webserver domain in the PS_CFG_HOME
for file in "$PS_CFG_HOME"/webserv/*/fileRealm.properties; do
#get the webserver instance name from the directory path
subdir=$(dirname "${file}")
webserver=$subdir
weblogicdomain=$(echo "cat //*[local-name()='domain']/*[local-name()='name']/text()"| xmllint --shell "$webserver/config/config.xml" | grep -v "/ >" | grep -v " -------")
piadomains+=($weblogicdomain)
done;
echo webservers=${piadomains[*]}
#Find each appserver domain in the PS_CFG_HOME
for file in "$PS_CFG_HOME"/appserv/*/psappsrv.cfg; do
#test if psappsrv.cfg file exists in the depths expected
#get the appserver instance name from the directory path
fullsubdir=$(dirname "${file}")
appserver=$(basename $fullsubdir)
appserverdomains+=($appserver)
done;
echo appservers=${appserverdomains[*]}
#Find each prcs scheduler domain in the PS_CFG_HOME
for file in "$PS_CFG_HOME"/appserv/prcs/*/psprcs.cfg; do
fullsubdir=$(dirname "${file}")
prcsserver=$(basename $fullsubdir)
prcsdomains+=${prcsserver[*]}
done;
echo process_scheduler=${prcsdomains[*]}
echo "###########################################################"
#Check if restart options set to start only
if [ "@option.StartOrStop@" = "start" ] ; then
echo "option start selected, skipping stop and clear steps"
else
#STOPPING SERVICES
if [ "@option.includeprcs@" = "yes" ] ; then
for i in ${prcsdomains[*]}; do
echo "###########################################################"
echo "attempting to stop tuxedo process scheduler domain" $i
echo "###########################################################"
psadmin -p kill -d $i
#manually remove process scheduler cache clean IPC resources
echo "cleaning up process scheduler cache at $PS_CFG_HOME/appserv/prcs/$i/CACHE"
rm -rf $PS_CFG_HOME/appserv/prcs/$i/CACHE/*
echo "Cleaning IPC resources for prcsserver" $i
psadmin -p cleanipc -d $i
echo "exit status=" $?
done;
fi
if [ "@option.includeweb@" = "yes" ] ; then
for i in ${piadomains[*]}; do
#Using script due to bug stated below
#Trying to Start or Stop WebLogic using psadmin while using Cron Results in Error - General Exception: null - java.lang.NullPointerException (Doc ID 1908227.1)
echo "###########################################################"
echo "attempting to stop weblogic domain" $i
echo "###########################################################"
$PS_CFG_HOME/webserv/$i/bin/stopPIA.sh
#manually remove web cache
echo "cleaning up web cache at $PS_CFG_HOME/webserv/$i/applications/peoplesoft/PORTAL.war/$i/cache"
rm $PS_CFG_HOME/webserv/$i/applications/peoplesoft/PORTAL.war/$i/cache/*
echo "exit status=" $?
done;
fi
if [ "@option.includeapp@" = "yes" ] ; then
for i in ${appserverdomains[*]}; do
echo "###########################################################"
echo "attempting to stop tuxedo appserver domain" $i
echo "###########################################################"
psadmin -c shutdown! -d $i
#CACHE CLEANUP
echo "Cleaning IPC resources for appserver" $i
psadmin -c cleanipc -d $i
echo "attempting to clear cache for" $i
echo "this may take a minute"
psadmin -c purge -d $i
echo "exit status=" $?
done;
fi
fi
#STARTING SERVICES
if [ "@option.StartOrStop@" = "restart" ] || [ "@option.StartOrStop@" = "start" ] ; then
#To Start Process Schedulers
if [ "@option.includeprcs@" = "yes" ] ; then
for i in ${prcsdomains[*]}; do
echo "###########################################################"
echo "attempting to start tuxedo process scheduler domain" $i
echo "###########################################################"
psadmin -p start -d $i
done;
fi
#To start appservers
if [ "@option.includeapp@" = "yes" ] ; then
for i in ${appserverdomains[*]}; do
echo "###########################################################"
echo "attempting to start tuxedo appserver domain" $i
echo "###########################################################"
psadmin -c boot -d $i
done;
fi
#To start webservers
if [ "@option.includeweb@" = "yes" ] ; then
for i in ${piadomains[*]}; do
#Using script due to bug stated below
#Trying to Start or Stop WebLogic using psadmin while using Cron Results in Error - General Exception: null - java.lang.NullPointerException (Doc ID 1908227.1)
echo "###########################################################"
echo "attempting to start weblogic domain" $i
echo "###########################################################"
$PS_CFG_HOME/webserv/$i/bin/startPIA.sh
done;
fi
fi
keepgoing: false
strategy: node-first
uuid: ed3f817e-0e46-48fc-b609-1a4387ee99bd
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment