nodemanager.erb 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  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. if test -f /lib/lsb/init-functions; then
  29. . /lib/lsb/init-functions
  30. fi
  31. . /etc/init.d/functions
  32. # set NodeManager environment
  33. NodeManagerLockFile=<%= @nodeMgrLckFile %>
  34. exec=<%= @nodeMgrBinPath %>/startNodeManager.sh
  35. prog='nodemanager'
  36. user='<%= @user %>'
  37. <% if @jsseEnabled == true %>
  38. JSEE_OPTIONS="-Dweblogic.ssl.JSSEEnabled=true -Dweblogic.security.SSL.enableJSSE=true"
  39. <% else %>
  40. JSEE_OPTIONS="-Dweblogic.ssl.JSSEEnabled=false -Dweblogic.security.SSL.enableJSSE=false"
  41. <% end %>
  42. is_nodemgr_running() {
  43. local nodemgr_cnt=`ps -ef | \
  44. grep -i 'java ' | \
  45. grep -i ' weblogic.NodeManager ' | \
  46. grep -v grep | \
  47. wc -l`
  48. echo $nodemgr_cnt
  49. }
  50. get_nodemgr_pid() {
  51. nodemgr_pid=0
  52. if [ `is_nodemgr_running` -eq 1 ]; then
  53. nodemgr_pid=`ps -ef | \
  54. grep -i 'java ' | \
  55. grep -i ' weblogic.NodeManager ' | \
  56. grep -v grep | \
  57. tr -s ' ' | \
  58. cut -d' ' -f2`
  59. fi
  60. echo $nodemgr_pid
  61. }
  62. check_nodemgr_status () {
  63. local retval=0
  64. local nodemgr_cnt=`is_nodemgr_running`
  65. if [ $nodemgr_cnt -eq 0 ]; then
  66. if [ -f $NodeManagerLockFile ]; then
  67. retval=2
  68. else
  69. retval=3
  70. fi
  71. elif [ $nodemgr_cnt -gt 1 ]; then
  72. retval=4
  73. else
  74. retval=0
  75. fi
  76. echo $retval
  77. }
  78. start() {
  79. ulimit -n 65535
  80. [ -x $exec ] || exit 5
  81. echo -n $"Starting $prog: "
  82. sleep 10
  83. su $user -c "export JAVA_OPTIONS='${JSEE_OPTIONS}';$exec &"
  84. retval=$?
  85. echo
  86. return $retval
  87. }
  88. stop() {
  89. echo -n $"Stopping $prog: "
  90. kill -s 9 `get_nodemgr_pid` &> /dev/null
  91. retval=$?
  92. echo
  93. [ $retval -eq 0 ] && rm -f $NodeManagerLockFile
  94. return $retval
  95. }
  96. restart() {
  97. stop
  98. start
  99. }
  100. reload() {
  101. restart
  102. }
  103. force_reload() {
  104. restart
  105. }
  106. rh_status() {
  107. local retval=`check_nodemgr_status`
  108. if [ $retval -eq 0 ]; then
  109. echo "$prog (pid:`get_nodemgr_pid`) is running..."
  110. elif [ $retval -eq 4 ]; then
  111. echo "Multiple instances of $prog are running..."
  112. else
  113. echo "$prog is stopped"
  114. fi
  115. return $retval
  116. }
  117. rh_status_q() {
  118. rh_status >/dev/null 2>&1
  119. }
  120. case "$1" in
  121. start)
  122. rh_status_q && exit 0
  123. $1
  124. ;;
  125. stop)
  126. rh_status_q || exit 0
  127. $1
  128. ;;
  129. restart)
  130. $1
  131. ;;
  132. reload)
  133. rh_status_q || exit 7
  134. $1
  135. ;;
  136. force-reload)
  137. force_reload
  138. ;;
  139. status)
  140. rh_status
  141. ;;
  142. condrestart|try-restart)
  143. rh_status_q || exit 0
  144. restart
  145. ;;
  146. *)
  147. echo -n "Usage: $0 {"
  148. echo -n "start|"
  149. echo -n "stop|"
  150. echo -n "status|"
  151. echo -n "restart|"
  152. echo -n "condrestart|"
  153. echo -n "try-restart|"
  154. echo -n "reload|"
  155. echo -n "force-reload"
  156. echo "}"
  157. exit 2
  158. esac
  159. exit $?