Building better stop scripts for Oracle E-Business Suite - gracefully stopping managers
source /u01/install/APPS/EBSapps.env run; adstpall.sh -mode=allnodes
However, in practice, doing so envelops some issues:
- You'll have to enter the apps and WebLogic password,
- running concurrent processes might cause issues.
Passing apps and WebLogic password
If you want to entirely automate the shutdown, you don't want to enter the apps and WebLogic password manually. This is especially necessary should you decide to gracefully stop your dev/test environment every night to safe on Infrastructure and Licensing costs on OCI, as described in this previous blog post. As described both over there and with some more details regarding the OCI Vault service here, that can be solved easily with some lines as follows:
adstpall.sh -mode=allnodes apps/$XX_APPS_PWD << EOF $XX_WEBLOGIC_PWD EOF
Stopping E-Business Suite Concurrent Managers
A more complex issue I've seen in a lot of customer environments is that just stopping the "internal concurrent manager" might be too aggressive. Think of a concurrent request starting other requests and waiting for them. If you shut down the environment without further measures before such child requests have kicked off, they will never start and the parent request will wait forever, preventing the shutdown of the concurrent manager.
A possible solution for this is to put the parent and the child request to different concurrent managers. That way, you can first stop the concurrent manager running the parent program and only stop the manager that runs the child processes after all the parent requests are completed.
With that, you're able to define an "order" in which you can shut down the concurrent managers so that the process reproducible succeeds with arbitrary starting points.
Automating the stopping of Concurrent Managers
The procedure shown above requires quite the manual effort. I've seen customers that had 5-10 "stages" in which the various concurrent managers had to be stopped. Unfortunately, by using some "semi-documented" APIs, it's possible to stop (and later start) these concurrent managers through scripts.
I've implemented this with the following bash helper function:
function stopManager { stop_initiated=0 for (( ; ; )) do res=`sqlplus -s apps/$XX_APPS_PWD << EOF set pages 0 set head off set feed off SELECT running_processes FROM fnd_concurrent_queues WHERE concurrent_queue_name ='$2' ; EXIT; EOF` echo running processes for $2 is: $res if [ "$res" -eq "0" ]; then break fi if [ "$stop_initiated" -eq "0" ]; then CONCSUB apps/$XX_APPS_PWD SYSADMIN 'System Administrator' SYSADMIN CONCURRENT FND DEACTIVATE $1 $2 stop_initiated=1 fi sleep 5 done }
The function runs in a loop and has the following core components:
- It checks if the manager is (still) running using a sqlplus select.
- It stops the manager using CONCSUB.
The function is called with the Application Short Name and the name of the manager to stop.
By using this helper function, you can then have a main script as follows:
source /home/oracle/credsEnv.sh source /u01/install/APPS/EBSapps.env run; stopManager XXIS XX_RESTART_NP_MANAGER stopManager FND XX_NP_MANAGER #next in parallel: stopManager FND XX_NP_MANAGER_1 & stopManager FND XX_NP_MANAGER_2 & stopManager FND XX_NP_MANAGER_3 & wait stopManager FND XX_MMP_MANAGER
This process first stops XX_RESTART_NP_MANAGER, after this is completed, it stops XX_NP_MANAGER.
Then, XX_NP_MANAGER_1, XX_NP_MANAGER_2 and XX_NP_MANAGER_3 are stopped in parallel (to save time).
Finally, we stop XX_MMP_MANAGER.
Bringing everything back up
Restarting the concurrent managers is straightforward, and usually, it is not necessary to wait until each stage is completed:
CONCSUB apps/$XX_APPS_PWD SYSADMIN 'System Administrator' SYSADMIN CONCURRENT FND ACTIVATE XXIS XX_RESTART_NP_MANAGER CONCSUB apps/$XX_APPS_PWD SYSADMIN 'System Administrator' SYSADMIN CONCURRENT FND ACTIVATE FND XX_NP_MANAGER
Summary
With the above-mentioned script and especially by leveraging CONCSUB (documented in 147449.1), it is easily possible to automate a "proper and robust" and yet "graceful" way of shutting down Oracle E-Business Suite. This is handy in many automation scenarios - no matter whether it is stopping dev/test to save money or automating patching.