nodemanager.erb 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  1. #!/bin/sh
  2. #
  3. ### BEGIN INIT INFO
  4. # Provides: nodemanager
  5. # Required-Start:
  6. # Required-Stop:
  7. # Default-Start: 2 3 4 5
  8. # Default-Stop: 0 1 6
  9. # Short-Description: WebLogic Nodemanager
  10. ### END INIT INFO
  11. # nodemgr Oracle Weblogic NodeManager service
  12. #
  13. # chkconfig: 345 99 15
  14. # description: Oracle Weblogic NodeManager service
  15. #
  16. ### BEGIN INIT INFO
  17. # Provides: nodemgr
  18. # Required-Start: $network $local_fs
  19. # Required-Stop:
  20. # Should-Start:
  21. # Should-Stop:
  22. # Default-Start: 3 4 5
  23. # Default-Stop: 0 1 2 6
  24. # Short-Description: Oracle Weblogic NodeManager service.
  25. # Description: Starts and stops Oracle Weblogic NodeManager.
  26. ### END INIT INFO
  27. # Source function library.
  28. . /lib/lsb/init-functions
  29. # set NodeManager environment
  30. NodeManagerLockFile=<%= @nodeMgrLckFile %>
  31. exec=<%= @nodeMgrBinPath %>/startNodeManager.sh
  32. prog='nodemanager'
  33. user='<%= @user %>'
  34. is_nodemgr_running() {
  35. local nodemgr_cnt=`ps -ef | \
  36. grep -i 'java ' | \
  37. grep -i ' weblogic.NodeManager ' | \
  38. grep -v grep | \
  39. wc -l`
  40. echo $nodemgr_cnt
  41. }
  42. get_nodemgr_pid() {
  43. nodemgr_pid=0
  44. if [ `is_nodemgr_running` -eq 1 ]; then
  45. nodemgr_pid=`ps -ef | \
  46. grep -i 'java ' | \
  47. grep -i ' weblogic.NodeManager ' | \
  48. grep -v grep | \
  49. tr -s ' ' | \
  50. cut -d' ' -f2`
  51. fi
  52. echo $nodemgr_pid
  53. }
  54. check_nodemgr_status () {
  55. local retval=0
  56. local nodemgr_cnt=`is_nodemgr_running`
  57. if [ $nodemgr_cnt -eq 0 ]; then
  58. if [ -f $NodeManagerLockFile ]; then
  59. retval=2
  60. else
  61. retval=3
  62. fi
  63. elif [ $nodemgr_cnt -gt 1 ]; then
  64. retval=4
  65. else
  66. retval=0
  67. fi
  68. echo $retval
  69. }
  70. start() {
  71. ulimit -n 65535
  72. [ -x $exec ] || exit 5
  73. echo -n $"Starting $prog: "
  74. sleep 10
  75. su $user -c "$exec &"
  76. retval=$?
  77. echo
  78. return $retval
  79. }
  80. stop() {
  81. echo -n $"Stopping $prog: "
  82. kill -s 9 `get_nodemgr_pid` &> /dev/null
  83. retval=$?
  84. echo
  85. [ $retval -eq 0 ] && rm -f $NodeManagerLockFile
  86. return $retval
  87. }
  88. restart() {
  89. stop
  90. start
  91. }
  92. reload() {
  93. restart
  94. }
  95. force_reload() {
  96. restart
  97. }
  98. rh_status() {
  99. local retval=`check_nodemgr_status`
  100. if [ $retval -eq 0 ]; then
  101. echo "$prog (pid:`get_nodemgr_pid`) is running..."
  102. elif [ $retval -eq 4 ]; then
  103. echo "Multiple instances of $prog are running..."
  104. else
  105. echo "$prog is stopped"
  106. fi
  107. return $retval
  108. }
  109. rh_status_q() {
  110. rh_status >/dev/null 2>&1
  111. }
  112. case "$1" in
  113. start)
  114. rh_status_q && exit 0
  115. $1
  116. ;;
  117. stop)
  118. rh_status_q || exit 0
  119. $1
  120. ;;
  121. restart)
  122. $1
  123. ;;
  124. reload)
  125. rh_status_q || exit 7
  126. $1
  127. ;;
  128. force-reload)
  129. force_reload
  130. ;;
  131. status)
  132. rh_status
  133. ;;
  134. condrestart|try-restart)
  135. rh_status_q || exit 0
  136. restart
  137. ;;
  138. *)
  139. echo -n "Usage: $0 {"
  140. echo -n "start|"
  141. echo -n "stop|"
  142. echo -n "status|"
  143. echo -n "restart|"
  144. echo -n "condrestart|"
  145. echo -n "try-restart|"
  146. echo -n "reload|"
  147. echo -n "force-reload"
  148. echo "}"
  149. exit 2
  150. esac
  151. exit $?