|
| 1 | +#!/bin/bash |
| 2 | +# |
| 3 | +# start script |
| 4 | +# |
| 5 | +PasoeName=HelloWorldPasoe |
| 6 | +Dlc=/psc/dlc |
| 7 | +Pasoe=/psc/wrk/${PasoeName} |
| 8 | +PasoeLogs=${Pasoe}/logs |
| 9 | +PasoeBin=${Pasoe}/bin |
| 10 | +PasoeAgentLog=${PasoeLogs}/${PasoeName}.agent.`date +%Y-%m-%d`.log |
| 11 | +TimeOut=60 |
| 12 | + |
| 13 | +if [ -r "${PasoeLogs}/*" ] ; then |
| 14 | + echo "# Cleaning logs in : ${PasoeLogs}" |
| 15 | + rm ${PasoeLogs}/* |
| 16 | +fi |
| 17 | + |
| 18 | +# Start the appserver |
| 19 | + |
| 20 | +${PasoeBin}/tcman.sh start -v |
| 21 | +echo "#########################################################" |
| 22 | +echo "# #" |
| 23 | +echo "# Starting Docker Container #" |
| 24 | +echo "# #" |
| 25 | +echo "#########################################################" |
| 26 | +echo "# Waiting until the Catalina starts #" |
| 27 | +echo "#########################################################" |
| 28 | +i=0 |
| 29 | +until [ -f "${PasoeLogs}/catalina.out" ] |
| 30 | +do |
| 31 | + sleep 1 |
| 32 | + printf "." |
| 33 | + ((i=i+1)) |
| 34 | + if [ ${i} -ge ${TimeOut} ] ; then |
| 35 | + echo "#########################################################" |
| 36 | + echo "# Error: Catalina was not able to start #" |
| 37 | + echo "#########################################################" |
| 38 | + cat ${PasoeLogs}/* |
| 39 | + ls -ltr ${PasoeLogs}/* |
| 40 | + bash |
| 41 | + exit 1 |
| 42 | + fi |
| 43 | +done |
| 44 | +# Give the Catalina some time to log something useful |
| 45 | +sleep 3 |
| 46 | +cat ${PasoeLogs}/catalina.out |
| 47 | + |
| 48 | +echo "#########################################################" |
| 49 | +echo "# Waiting until the Pasoe agent starts #" |
| 50 | +echo "#########################################################" |
| 51 | +echo "Searching for file: ${PasoeAgentLog}" |
| 52 | + |
| 53 | +i=0 |
| 54 | +until [ -f "${PasoeAgentLog}" ] ; do |
| 55 | + sleep 1 |
| 56 | + printf "." |
| 57 | + ((i=i+1)) |
| 58 | + if [ ${i} -ge ${TimeOut} ] ; then |
| 59 | + echo "#########################################################" |
| 60 | + echo "# Error: the Pasoe agent was not able to start #" |
| 61 | + echo "#########################################################" |
| 62 | + cat ${PasoeLogs}/* |
| 63 | + ls -ltr ${PasoeLogs}/* |
| 64 | + bash |
| 65 | + exit 1 |
| 66 | + fi |
| 67 | +done |
| 68 | + |
| 69 | +printf "\n" |
| 70 | + |
| 71 | +if [ "x$1" != "xmenu" ] ; then |
| 72 | + first=true |
| 73 | +else |
| 74 | + first=false |
| 75 | +fi |
| 76 | + |
| 77 | +until [ "${Answer}" = "x" ] ; do |
| 78 | + Answer="?" |
| 79 | + |
| 80 | + if [ x${first} = xtrue ] ; then |
| 81 | + Answer=c |
| 82 | + first=false |
| 83 | + else |
| 84 | + echo "\n#########################################################" |
| 85 | + echo "# p - Escape to proenv #" |
| 86 | + echo "# x - Stop the Docker container #" |
| 87 | + echo "# c - Continue #" |
| 88 | + echo "# l - List Pasoe logs directory #" |
| 89 | + echo "# b - List agent logfile from the beginning #" |
| 90 | + echo "# a - List all logfiles in /logs #" |
| 91 | + read -rsn1 Answer |
| 92 | + fi |
| 93 | + |
| 94 | + case "${Answer}" in |
| 95 | + "p") ${Dlc}/bin/proenv ;; |
| 96 | + "c") tail -f ${PasoeAgentLog} ;; |
| 97 | + "l") ls -ltr ${PasoeLogs} ;; |
| 98 | + "b") cat ${PasoeAgentLog} ;; |
| 99 | + "l") cat ${PasoeLogs}/* ;; |
| 100 | + "x") exit 0 ;; |
| 101 | + esac |
| 102 | +done |
| 103 | + |
| 104 | + |
0 commit comments