ipfcst-server.sh 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  1. #!/bin/sh
  2. export basedir=/home/syjy/ipfcstV3
  3. export bindir=$basedir/produce
  4. export start_console_log=$basedir/logs/start_console.log
  5. export start_reportquery_log=$basedir/logs/start_reportquery.log
  6. export start_monitor_log=$basedir/logs/start_monitor.log
  7. export monitor_version="1.0.0"
  8. export console_version="1.0.0"
  9. export reportquery_version="1.0.0"
  10. export monitor_path=$bindir/monitor/$monitor_version
  11. export console_path=$bindir/console/$console_version
  12. export reportquery_path=$bindir/reportquery/$reportquery_version
  13. export service_startup_timeout=900
  14. log_success_msg() {
  15. echo " SUCCESS! $@"
  16. }
  17. log_failure_msg() {
  18. echo " ERROR! $@"
  19. }
  20. case "$1" in
  21. console-start)
  22. cd $console_path
  23. echo $echo_n "Starting Console"
  24. if test -x $console_path/ipfcst-console.jar
  25. then
  26. java -jar $console_path/ipfcst-console.jar >$start_console_log &
  27. echo $echo_n "Console started, PID is $!"
  28. else
  29. log_failure_msg "Couldn't find Console server($bindir/ipfcst-console.jar)"
  30. fi
  31. ;;
  32. console-stop)
  33. echo $echo_n "Shutting down console"
  34. pid_list="$(ps aux | grep ipfcst-console | grep -v grep | awk '{print $2}')"
  35. if test -z $pid_list ; then
  36. echo "console is not running"
  37. else
  38. for pid in $pid_list;
  39. do
  40. if kill -0 "$pid" 2>/dev/null; then
  41. echo "kill pid $pid"
  42. kill -9 $pid
  43. fi
  44. done
  45. fi
  46. ;;
  47. console-restart)
  48. if $0 console-stop ; then
  49. $0 console-start
  50. else
  51. log_failure_msg "Failed to stop running server, so refusing to try to start."
  52. exit 1
  53. fi
  54. ;;
  55. console-status)
  56. pid_list="$(ps aux | grep ipfcst-console | grep -v grep | awk '{print $2}')"
  57. pid_count=`echo $pid_list | wc -w`
  58. if test $pid_count -eq 1 ; then
  59. echo "Console running, pid is $pid_list"
  60. exit 0
  61. elif test $pid_count -gt 1 ; then
  62. echo "Multiple Console running $pid_list"
  63. exit 1
  64. elif test -z $pid_list ; then
  65. echo "Console is not running"
  66. exit 1
  67. fi
  68. ;;
  69. reportquery-start)
  70. cd $reportquery_path
  71. echo $echo_n "Starting Reportquery"
  72. if test -x $reportquery_path/ipfcst-reportquery.jar
  73. then
  74. java -jar $reportquery_path/ipfcst-reportquery.jar >$start_reportquery_log &
  75. echo $echo_n "Reportquery started, PID is $!"
  76. else
  77. log_failure_msg "Couldn't find Reportquery server($bindir/ipfcst-reportquery.jar)"
  78. fi
  79. ;;
  80. reportquery-stop)
  81. echo $echo_n "Shutting down reportquery"
  82. pid_list="$(ps aux | grep ipfcst-reportquery | grep -v grep | awk '{print $2}')"
  83. if test -z $pid_list ; then
  84. echo "reportquery is not running"
  85. else
  86. for pid in $pid_list;
  87. do
  88. if kill -0 "$pid" 2>/dev/null; then
  89. echo "kill pid $pid"
  90. kill -9 $pid
  91. fi
  92. done
  93. fi
  94. ;;
  95. reportquery-restart)
  96. if $0 reportquery-stop ; then
  97. $0 reportquery-start
  98. else
  99. log_failure_msg "Failed to stop running server, so refusing to try to start."
  100. exit 1
  101. fi
  102. ;;
  103. reportquery-status)
  104. pid_list="$(ps aux | grep ipfcst-reportquery | grep -v grep | awk '{print $2}')"
  105. pid_count=`echo $pid_list | wc -w`
  106. if test $pid_count -eq 1 ; then
  107. echo "Reportquery running, pid is $pid_list"
  108. exit 0
  109. elif test $pid_count -gt 1 ; then
  110. echo "Multiple Reportquery running $pid_list"
  111. exit 1
  112. elif test -z $pid_list ; then
  113. echo "Reportquery is not running"
  114. exit 1
  115. fi
  116. ;;
  117. monitor-start)
  118. cd $monitor_path
  119. echo $echo_n "Starting Monitor"
  120. if test -x $monitor_path/ipfcst-monitor.jar
  121. then
  122. java -jar $monitor_path/ipfcst-monitor.jar >$start_monitor_log &
  123. echo $echo_n "Monitor started, PID is $!"
  124. else
  125. log_failure_msg "Couldn't find Monitor server($monitor_path/ipfcst-monitor.jar)"
  126. fi
  127. ;;
  128. monitor-stop)
  129. echo $echo_n "Shutting down Monitor"
  130. pid_list="$(ps aux | grep ipfcst-monitor | grep -v grep | awk '{print $2}')"
  131. if test -z $pid_list ; then
  132. echo "Monitor is not running"
  133. else
  134. for pid in $pid_list;
  135. do
  136. if kill -0 "$pid" 2>/dev/null; then
  137. echo "kill pid $pid"
  138. kill -9 $pid
  139. fi
  140. done
  141. fi
  142. ;;
  143. monitor-restart)
  144. if $0 monitor-stop ; then
  145. $0 monitor-start
  146. else
  147. log_failure_msg "Failed to stop running server, so refusing to try to start."
  148. exit 1
  149. fi
  150. ;;
  151. monitor-status)
  152. pid_list="$(ps aux | grep ipfcst-monitor | grep -v grep | awk '{print $2}')"
  153. pid_count=`echo $pid_list | wc -w`
  154. if test $pid_count -eq 1 ; then
  155. echo "Monitor running, pid is $pid_list"
  156. exit 0
  157. elif test $pid_count -gt 1 ; then
  158. echo "Multiple Monitor running $pid_list"
  159. exit 1
  160. elif test -z $pid_list ; then
  161. echo "Monitor is not running"
  162. exit 1
  163. fi
  164. ;;
  165. *)
  166. # usage
  167. basename=`basename "$0"`
  168. echo "Usage: $basename {console-start|console-stop|console-restart|console-status|reportquery-start|reportquery-stop|reportquery-restart|reportquery-status|monitor-start|monitor-stop|monitor-restart|monitor-status} [ ipfcst server options ]"
  169. exit 1
  170. ;;
  171. esac
  172. exit 0