1. startup file: service-restart.sh
#!/bin/sh # java ENV source/etc/profile export java_home=/usr/local/jdk1.7.0_75 export jre_home= $JAVA _home/jre if [$# != 3];
Then echo "USAGE: $ service_dir service_name_pre disconf_env" echo "e.g.: $0/opt/dubbo-test Dubbo-goods Rd" Exit 1; Fi service_dir=$1 service_name_pre=$2 #设置 disconf information disconf_env=$3 disconf_host=192.168.0.11:8080 DISCONF_APP=dubbo DI sconf_version=1.0.0 echo "Service_dir" $SERVICE _dir echo "Service_name_pre" $SERVICE _name_pre echo "Disconf_env" $ Disconf_env echo "Disconf_host" $DISCONF _host echo "Disconf_app" $DISCONF _app echo "disconf_version" $DISCONF _version CD $SERVICE _dir # p_id= ' Ps-ef | Grep-w "$SERVICE _name_pre" | Grep-v "grep" | awk ' {print $} ' p_id= ' Jps-ml|grep ' $SERVICE _name_pre ' |awk ' {print '} ' 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 _idFi 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-RF Exit 0
2. Examples:
2.1. The first parameter is the directory where the executable jar file resides
2.2. The second parameter is the executable jar file name
2.3. The third parameter is the name of the environment
/opt/service-restart.sh/opt/test-service Test-service Rd