1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86
| # 项目名称 APP_NAME=safirst-etmf-api-1.0.0.jar # 启动方法,根据端口号启动 start_port() { echo "准备启动服务 ... $PORT" pid=$(netstat -an | grep $PORT | awk '{print $4}') echo "pid: $pid" if [[ -n $pid ]]; then echo "端口号 $PORT 的服务已启动" else echo "开始启动服务 ... $PORT" nohup java -jar $APP_NAME --server.port=${PORT} --logging.file.name=/mnt/nas/etmf/irzhd-logs-api-$PORT-105/spring.log > /dev/null & fi exit 1 } # 项目拷贝 copy_c() { FILE_NAME=$(date -d last-day +%Y%m%d) echo "开始备份项目" cp $APP_NAME ${APP_NAME}_${FILE_NAME} echo "备份完成 ${APP_NAME}_${FILE_NAME}" echo "开始拷贝项目" cp /mnt/nas/jar/$APP_NAME . echo "拷贝成功" exit 1 } # 服务停止 stop_s() { echo "端口号: $PORT" echo "开始停止 $PORT 端口号的服务" ps -ef | grep $PORT | grep -v grep | awk '{print $2}' | xargs kill -9 echo "服务停止成功" exit 1 } log_port() { tail -f /mnt/nas/etmf/irzhd-logs-api-$PORT-105/spring.log exit 1 } usage() { echo "Usage: ${0} [-s|--start] [-stop] [-c|--copy] [-l|--log]" 1>&2 exit 1 } while [[ $# -gt 0 ]];do key=${1} case ${key} in -s|--start) PORT=${2} if [[ ! -n $PORT ]]; then echo "请输入端口号 -s 12000" exit 1 else echo "启动服务,端口号: $PORT" shift 2 start_port fi ;; -c|--copy) copy_c shift 2 ;; -stop) PORT=${2} if [[ ! -n $PORT ]]; then echo "请输入端口号 -s 12000" exit 1 else stop_s shift 2 fi ;; -l|--log) PORT=${2} if [[ ! -n $PORT ]]; then echo "请输入端口号 -s 12000" exit 1 else log_port shift 2 fi ;; *) usage shift ;; esac done
|