#!/bin/sh set -e APP=$1 ENV=$2 time_tag=`date '+%Y-%m-%d'` HOST=`ifconfig | grep inet | grep -v inet6 | grep -v '127.0.0.1' | grep -v '0.0.0.0' | awk '{print $2}'` echo "host = ${HOST}" cd /opt/servers/jars/autodop if [ -d app ] then if [ -d app-${time_tag} ]; then rm -rf app-${time_tag} fi mv app app-${time_tag} tar vxf app.tar > /dev/null else tar vxf app.tar > /dev/null fi rm -rf app.tar # TODO 远程执行命令时导致系统用户 ID 不正确,需手动修改 chown -R root:root app cd app # jps | grep 1.0.0 | awk '{print $1}' | xargs kill -15 pid=`jps | grep 1.0.0 | awk '{print $1}'` echo "pid = ${pid}" if [ -z ${pid} ] then # TODO 判断进程是否成功启动 nohup ./${APP}-1.0.0.jar ./resources/sysconfig/sys-${ENV}.json > ${APP}.log & pid=`jps | grep 1.0.0 | awk '{print $1}'` echo "newpid = ${pid}" else kill -15 ${pid} nohup ./${APP}-1.0.0.jar ./resources/sysconfig/sys-${ENV}.json > ${APP}.log & pid=`jps | grep 1.0.0 | awk '{print $1}'` echo "newpid = ${pid}" fi exit 0