Authored by fangyeqing

ADD:添加启动停止脚本

  1 +#conf
  2 +cp src/main/resources/application.properties.online src/main/resources/application.properties
  3 +cp src/main/resources/public/index.html.online src/main/resources/public/index.html
  4 +
  5 +#path
  6 +project_path=$(cd `dirname $0`; cd ..; pwd)
  7 +log_path=${project_path}/log
  8 +pid_file=${project_path}/bin/pid
  9 +echo "INFO: project_path=${project_path}"
  10 +echo "INFO: log_path=${log_path}"
  11 +echo "INFO: pid_file=${pid_file}"
  12 +
  13 +#mkdir log
  14 +if [ -d ${log_path} ];then
  15 + echo "INFO: log/ exit"
  16 +else
  17 + echo "INFO: log/ not exit,create path log/"
  18 + mkdir ${log_path}
  19 +fi
  20 +
  21 +# Check pid file
  22 +if [[ -f $pid_file ]]; then
  23 + echo "Error: Service may be already started. Check the status first.";
  24 + exit 1;
  25 +fi
  26 +
  27 +# start
  28 +nohup mvn spring-boot:run >${log_path}/xkl.out &
  29 +
  30 +# write down the pid
  31 +pid=$!;
  32 +if [[ -z $pid ]]; then
  33 + echo "Error: cannot start the service."
  34 + exit 1
  35 +fi
  36 +echo ${pid} > ${pid_file}
  37 +echo "INFO: start newstat service"
  1 +#path
  2 +project_path=$(cd `dirname $0`; cd ..; pwd)
  3 +pid_file=${project_path}/bin/pid
  4 +echo "INFO: project_path=${project_path}"
  5 +echo "INFO: pid_file=${pid_file}"
  6 +
  7 +if [[ -f $pid_file ]]; then
  8 + pid=$(cat $pid_file);
  9 +else
  10 + echo "INFO: STOPPED";
  11 + echo "INFO: The service is already stopped. Cannot find the file $pid_file.";
  12 + exit 0;
  13 +fi
  14 +
  15 +if [[ -z "$pid" || ! -d /proc/$pid ]]; then
  16 + echo "INFO: STOPPED";
  17 + echo "INFO: The service' is already stopped. Cannot find its process.";
  18 + rm -rf $pid_file;
  19 + exit 0;
  20 +fi
  21 +
  22 +if [[ ! -O /proc/$pid ]]; then
  23 + echo "Error: the process with id $pid of the service is not owned by the user $USER." > /dev/stderr;
  24 + exit 1;
  25 +fi
  26 +
  27 +if kill -9 $pid; then
  28 + rm -rf $pid_file;
  29 + echo "INFO:service STOPPED";
  30 +else
  31 + echo "Error when stopping the service." > /dev/stderr;
  32 + exit 1;
  33 +fi