123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181 |
- #!/bin/sh
- export basedir=/home/syjy/ipfcstV3
- export bindir=$basedir/produce
- export start_console_log=$basedir/logs/start_console.log
- export start_reportquery_log=$basedir/logs/start_reportquery.log
- export start_monitor_log=$basedir/logs/start_monitor.log
- export monitor_version="1.0.0"
- export console_version="1.0.0"
- export reportquery_version="1.0.0"
- export monitor_path=$bindir/monitor/$monitor_version
- export console_path=$bindir/console/$console_version
- export reportquery_path=$bindir/reportquery/$reportquery_version
- export service_startup_timeout=900
- log_success_msg() {
- echo " SUCCESS! $@"
- }
- log_failure_msg() {
- echo " ERROR! $@"
- }
- case "$1" in
- console-start)
- cd $console_path
- echo $echo_n "Starting Console"
- if test -x $console_path/ipfcst-console.jar
- then
- java -jar $console_path/ipfcst-console.jar >$start_console_log &
- echo $echo_n "Console started, PID is $!"
- else
- log_failure_msg "Couldn't find Console server($bindir/ipfcst-console.jar)"
- fi
- ;;
- console-stop)
- echo $echo_n "Shutting down console"
- pid_list="$(ps aux | grep ipfcst-console | grep -v grep | awk '{print $2}')"
- if test -z $pid_list ; then
- echo "console is not running"
- else
- for pid in $pid_list;
- do
- if kill -0 "$pid" 2>/dev/null; then
- echo "kill pid $pid"
- kill -9 $pid
- fi
- done
- fi
- ;;
- console-restart)
- if $0 console-stop ; then
- $0 console-start
- else
- log_failure_msg "Failed to stop running server, so refusing to try to start."
- exit 1
- fi
- ;;
- console-status)
- pid_list="$(ps aux | grep ipfcst-console | grep -v grep | awk '{print $2}')"
- pid_count=`echo $pid_list | wc -w`
- if test $pid_count -eq 1 ; then
- echo "Console running, pid is $pid_list"
- exit 0
- elif test $pid_count -gt 1 ; then
- echo "Multiple Console running $pid_list"
- exit 1
- elif test -z $pid_list ; then
- echo "Console is not running"
- exit 1
- fi
- ;;
- reportquery-start)
- cd $reportquery_path
- echo $echo_n "Starting Reportquery"
- if test -x $reportquery_path/ipfcst-reportquery.jar
- then
- java -jar $reportquery_path/ipfcst-reportquery.jar >$start_reportquery_log &
- echo $echo_n "Reportquery started, PID is $!"
- else
- log_failure_msg "Couldn't find Reportquery server($bindir/ipfcst-reportquery.jar)"
- fi
- ;;
- reportquery-stop)
- echo $echo_n "Shutting down reportquery"
- pid_list="$(ps aux | grep ipfcst-reportquery | grep -v grep | awk '{print $2}')"
- if test -z $pid_list ; then
- echo "reportquery is not running"
- else
- for pid in $pid_list;
- do
- if kill -0 "$pid" 2>/dev/null; then
- echo "kill pid $pid"
- kill -9 $pid
- fi
- done
- fi
- ;;
- reportquery-restart)
- if $0 reportquery-stop ; then
- $0 reportquery-start
- else
- log_failure_msg "Failed to stop running server, so refusing to try to start."
- exit 1
- fi
- ;;
- reportquery-status)
- pid_list="$(ps aux | grep ipfcst-reportquery | grep -v grep | awk '{print $2}')"
- pid_count=`echo $pid_list | wc -w`
- if test $pid_count -eq 1 ; then
- echo "Reportquery running, pid is $pid_list"
- exit 0
- elif test $pid_count -gt 1 ; then
- echo "Multiple Reportquery running $pid_list"
- exit 1
- elif test -z $pid_list ; then
- echo "Reportquery is not running"
- exit 1
- fi
- ;;
- monitor-start)
- cd $monitor_path
- echo $echo_n "Starting Monitor"
- if test -x $monitor_path/ipfcst-monitor.jar
- then
- java -jar $monitor_path/ipfcst-monitor.jar >$start_monitor_log &
- echo $echo_n "Monitor started, PID is $!"
- else
- log_failure_msg "Couldn't find Monitor server($monitor_path/ipfcst-monitor.jar)"
- fi
- ;;
- monitor-stop)
- echo $echo_n "Shutting down Monitor"
- pid_list="$(ps aux | grep ipfcst-monitor | grep -v grep | awk '{print $2}')"
- if test -z $pid_list ; then
- echo "Monitor is not running"
- else
- for pid in $pid_list;
- do
- if kill -0 "$pid" 2>/dev/null; then
- echo "kill pid $pid"
- kill -9 $pid
- fi
- done
- fi
- ;;
- monitor-restart)
- if $0 monitor-stop ; then
- $0 monitor-start
- else
- log_failure_msg "Failed to stop running server, so refusing to try to start."
- exit 1
- fi
- ;;
- monitor-status)
- pid_list="$(ps aux | grep ipfcst-monitor | grep -v grep | awk '{print $2}')"
- pid_count=`echo $pid_list | wc -w`
- if test $pid_count -eq 1 ; then
- echo "Monitor running, pid is $pid_list"
- exit 0
- elif test $pid_count -gt 1 ; then
- echo "Multiple Monitor running $pid_list"
- exit 1
- elif test -z $pid_list ; then
- echo "Monitor is not running"
- exit 1
- fi
- ;;
- *)
- # usage
- basename=`basename "$0"`
- 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 ]"
- exit 1
- ;;
- esac
- exit 0
|