1
0

create-broker.sh 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  1. #!/bin/bash
  2. set -e
  3. yell() { printf "\033[1;6;37;41m$0: $*\033[0m\n" >&2; }
  4. die() {
  5. yell "$*"
  6. exit 111
  7. }
  8. try() { "$@" || die "FAIL: $*"; }
  9. cmd() {
  10. local info="${2:-$1}"
  11. echo "=================================================="
  12. echo -e "💡 $info "
  13. echo "=================================================="
  14. eval "$1"
  15. }
  16. # . /opt/IBM/ace-12.0.9.0/server/bin/mqsiprofile
  17. cat /opt/mdw/bars/broker_list
  18. config=$(cat /opt/mdw/bars/broker.log | tr ' ' '\n' | grep -vF 'BROKER\;EXECUTIONGROUP\;QM\;PORT\;MAXHEAP\;JAVAOSSTACK\;HTTP_PORT')
  19. target=$VAR2
  20. path=$VAR3
  21. BROKER=$VAR4
  22. AWAKE=$VAR5
  23. if [[ $target == "DRC" ]]; then
  24. if [[ $(mqsilist | grep "$BROKER" | grep "stopped") ]]; then
  25. if [[ $(dspmq | grep ${BROKER}.QM | grep "Ended") ]]; then
  26. try cmd "strmqm ${BROKER}.QM > output.log 2>&1 &" \
  27. "Start QM ${BROKER}.QM"
  28. sleep 30
  29. fi
  30. try cmd "mqsistart $BROKER > output.log 2>&1 &" \
  31. "Start Integration Node $BROKER"
  32. sleep $((2 * 60))
  33. fi
  34. fi
  35. while read -r line; do
  36. trimmed_line=$(echo "$line" | xargs)
  37. if [[ "$line" == "BROKER;EXECUTIONGROUP;QM;PORT;MAXHEAP;JAVAOSSTACK;HTTP_PORT;HTTPS_PORT;EMBEDDED_LISTENER" || "$trimmed_line" == "" ]]; then
  38. echo "No need to execute because is line 1 or blank"
  39. else
  40. broker=$(echo "$line" | cut -d';' -f 1)
  41. executiongroup=$(echo "$line" | cut -d';' -f 2)
  42. qm=$(echo "$line" | cut -d';' -f 3)
  43. port=$(echo "$line" | cut -d';' -f 4)
  44. maxHeap=$(echo "$line" | cut -d';' -f 5)
  45. osStack=$(echo "$line" | cut -d';' -f 6)
  46. httpPort=$(echo "$line" | cut -d';' -f 7)
  47. httpsPort=$(echo "$line" | cut -d';' -f 8)
  48. embListener=$(echo "$line" | cut -d';' -f 9)
  49. # cek jika belum ada directory
  50. # if [[ ! -d "$path/$broker" ]]; then
  51. # try cmd "mkdir -m 775 -p $path/$broker" \
  52. # "Create directory $broker"
  53. # fi
  54. if [[ ! $(mqsilist | grep "$broker") ]]; then
  55. try cmd "mqsicreatebroker $broker -q $qm -e $path/$broker" \
  56. "Create Integration Node $broker"
  57. try cmd "mqsichangeproperties $broker -b webadmin -o HTTPConnector -n port -v $port" \
  58. "Setup Integration Node port : $port"
  59. fi
  60. # start jika broker stop
  61. if [[ $(mqsilist | grep "$broker" | grep "stopped") ]]; then
  62. try cmd "mqsistart $broker" \
  63. "Start Integration Node $broker"
  64. fi
  65. # cek kalau belum ada executiongroup
  66. if [[ ! $(mqsilist "$broker" | grep "$executiongroup") ]]; then
  67. try cmd "mqsicreateexecutiongroup $broker -e $executiongroup" \
  68. "Create Intergration Server $executiongroup"
  69. try cmd "mqsichangeflowstats $broker -e $executiongroup -s -c inactive" \
  70. "Disable accumulation of statistics about message flow"
  71. try cmd "mqsichangeresourcestats $broker -e $executiongroup -c inactive" \
  72. "Disable control statistics gathering for resources"
  73. fi
  74. # Cek kalau executiongroup is stop
  75. if [[ $(mqsilist "$broker" | grep "$executiongroup" | grep "stopped") ]]; then
  76. try cmd "mqsistart $broker -e $executiongroup -w 1800" \
  77. "Start Integration Server $executiongroup"
  78. fi
  79. # cek jika tidak null broker properties MAXHEAP
  80. if [[ ! "$(mqsireportproperties "$broker" -e "$executiongroup" -o ComIbmJVMManager -n jvmMaxHeapSize | grep -vE '^$|BIP')" == "$maxHeap" ]]; then
  81. try cmd "mqsichangeproperties $broker -e $executiongroup -o ComIbmJVMManager -n jvmMaxHeapSize -v $maxHeap" \
  82. "Change properties jvmMaxHeapSize $maxHeap"
  83. fi
  84. # cek jika tidak null broker properties JAVOSSTACK
  85. if [[ ! "$(mqsireportproperties "$broker" -e "$executiongroup" -o ComIbmJVMManager -n jvmJavaOSStackSize | grep -vE '^$|BIP')" == "$osStack" ]]; then
  86. try cmd "mqsichangeproperties $broker -e $executiongroup -o ComIbmJVMManager -n jvmJavaOSStackSize -v $osStack" \
  87. "Change properties jvmJavaOSStackSize $osStack"
  88. try cmd "mqsichangeproperties $broker -e $executiongroup -o ComIbmJVMManager -n jvmSystemProperty -v \"-Dlogback.configurationFile=/opt/mdw/jplugin/logback.xml\"" \
  89. "Change properties jvmSystemProperty $executiongroup '-Dlogback.configurationFile=/opt/mdw/jplugin/logback.xml'"
  90. fi
  91. if [[ -z "$httpPort" ]]; then
  92. echo "httpPort is empty or unset"
  93. else
  94. try cmd "mqsichangeproperties $broker -e $executiongroup -o HTTPConnector -n ListenerPort -v $httpPort" \
  95. "Change properties HTTPConnector ListenerPort $httpPort"
  96. fi
  97. if [[ -z "$httpsPort" ]]; then
  98. echo "httpsPort is empty or unset"
  99. else
  100. try cmd "mqsichangeproperties $broker -e $executiongroup -o HTTPSConnector -n ListenerPort -v $httpsPort" \
  101. "Change properties HTTPSConnector ListenerPort $httpsPort"
  102. fi
  103. if [[ $target == "DC" ]]; then
  104. if [[ $(mqsilist "$broker" | grep "$executiongroup" | grep "stopped") ]]; then
  105. echo "no need to start, beacause executiongroup is stop"
  106. else
  107. try cmd "mqsistop $broker -e $executiongroup -w 1800" \
  108. "Stop Integration Server $executiongroup"
  109. fi
  110. if [[ -z "$embListener" ]]; then
  111. echo "Embedded Listerner is empty or unset"
  112. else
  113. try cmd "mqsichangeproperties $broker -f -e $executiongroup -o ExecutionGroup -n httpNodesUseEmbeddedListener -v true" \
  114. "Change properties ExecutionGroup httpNodesUseEmbeddedListener $embListener"
  115. fi
  116. try cmd "mqsistart $broker -e $executiongroup -w 1800" \
  117. "Start Integration Server $executiongroup"
  118. fi
  119. fi
  120. done <<<"$config"
  121. if [[ $target == "DRC" && $AWAKE == false ]]; then
  122. try cmd "mqsistop $BROKER > output.log 2>&1 &" \
  123. "Stop Integration Node $BROKER"
  124. sleep $((2 * 60))
  125. try cmd "endmqm -i $qm" \
  126. "Stop QM $qm"
  127. sleep $((2 * 60))
  128. fi