process_is_running(){ pid=get_pid if [ -z $pid ] then echo 1 else echo 0 fi }
start() { cp ${jar_path}/${s_jar_name} ${jar_path}/${jar_name} pid=get_pid if test process_is_running -eq 0 then echo "WARN:process is running,pid is $pid" exit 1 else echo "Starting server: " JVM_OPTS="-server -Xms4G -Xmx4G -XX:MaxMetaspaceSize=256M -XX:MetaspaceSize=256M -Xloggc:${logs}/gc.log -XX:-PrintGCDetails -XX:+PrintGCDateStamps -XX:+PrintGCApplicationStoppedTime -XX:+UseConcMarkSweepGC -XX:CMSInitiatingOccupancyFraction=70 -XX:+UseCMSCompactAtFullCollection -XX:+CMSParallelRemarkEnabled -XX:+HeapDumpOnOutOfMemoryError" echo "java ${JVM_OPTS} -Dspring.config.location=classpath:application.properties,classpath:application.yml,file:${APP_HOME}/conf/application.properties -jar ${jar_path}/${jar_name}" setsid su hdfs -c "java ${JVM_OPTS} -Dapp.log.home=${logs} -Dspring.config.location=classpath:application.properties,classpath:application.yml,file:${APP_HOME}/conf/application.properties,file:${APP_HOME}/conf/application.yml -jar ${jar_path}/${jar_name} --server.port=${server_port} > ${startlog} 2>&1 &" sleep 2s pid=get_pid if test process_is_running -eq 0 then echo "start success! pid is $pid" else echo "start fail." fi fi }
stop() { pid=get_pid if test process_is_running -eq 0 then echo "stopping..." pid=get_pid kill -9 $pid if test process_is_running -eq 0 then echo "stop fail" else echo "stop success" fi else echo "WARN:process is not exist." fi }
restart() { stop start }
rh_status() { pid=get_pid if test process_is_running -eq 0 then echo "process is running,pid is $pid" else echo "process is not running" fi RETVAL=$? return $RETVAL }