disconf java 啟動 shell

來源:互聯網
上載者:User

1.開機檔案: service-restart.sh

#!/bin/sh## java envsource /etc/profileexport JAVA_HOME=/usr/local/jdk1.7.0_75export JRE_HOME=$JAVA_HOME/jreif [ $# != 3 ] ; then echo "USAGE: $0 SERVICE_DIR SERVICE_NAME_PRE DISCONF_ENV" echo " e.g.: $0 /opt/dubbo-test dubbo-goods rd" exit 1; fi SERVICE_DIR=$1SERVICE_NAME_PRE=$2#設定 disconf 資訊DISCONF_ENV=$3DISCONF_HOST=192.168.0.11:8080DISCONF_APP=dubboDISCONF_VERSION=1.0.0echo "SERVICE_DIR" $SERVICE_DIRecho "SERVICE_NAME_PRE" $SERVICE_NAME_PREecho "DISCONF_ENV" $DISCONF_ENVecho "DISCONF_HOST" $DISCONF_HOSTecho "DISCONF_APP" $DISCONF_APPecho "DISCONF_VERSION" $DISCONF_VERSIONcd $SERVICE_DIR#        P_ID=`ps -ef | grep -w "$SERVICE_NAME_PRE" | grep -v "grep" | awk '{print $2}'`    P_ID=`jps -ml|grep "$SERVICE_NAME_PRE"|awk '{print $1}'`         if [ "$P_ID" == "" ]; then            echo "=== $SERVICE_NAME process not exists or stop success"        else            echo "=== begin kill $SERVICE_NAME process, pid is:$P_ID"            kill -9 $P_ID       fi    sleep 3    JAR_NAME=`ls -rt *.jar|grep -v 'sources'|tail -1`    echo "START JAR_NAME "$JAR_NAME    nohup $JRE_HOME/bin/java -Xms256m -Xmx512m -jar   -Ddisconf.env=$DISCONF_ENV -Ddisconf.conf_server_host=$DISCONF_HOST -Ddisconf.app=$DISCONF_APP -Ddisconf.version=$DISCONF_VERSION -Ddisconf.user_define_download_dir=.classes -Ddisconf.enable.remote.conf=true          $JAR_NAME >$SERVICE_NAME_PRE.log 2>&1 &    ls *.jar|grep -v $JAR_NAME|xargs rm -rfexit 0

2.例子:
2.1.第一個參數是可執行 jar 檔案所在目錄
2.2.第二個參數是可執行 jar 檔案名稱
2.3.第三個參數是環境名稱

/opt/service-restart.sh /opt/test-service test-service rd
相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.