linux 部署腳本
阿新 • • 發佈:2018-07-02
warning opts v_op 環境 虛擬機 ready walle path 方法
shell 腳本
#!/bin/bash #設置jdk環境 export JAVA_HOME=/usr/java/jdk1.8.0_45 export JRE_HOME=$JAVA_HOME/jre export CLASSPATH=.:$JAVA_HOME/lib:$JRE_HOME/lib:$CLASSPATH export PATH=$JAVA_HOME/bin:$JRE_HOME/bin:$PATH ################################### #環境變量及程序執行參數 #需要根據實際環境以及Java程序名稱來修改這些參數 ################################### #需要啟動的Java主程序(main方法類) JAR_FILE="schedule.server-1.0-SNAPSHOT.jar" #項目路徑 APP_HOME="/home/robin/wallet_push" #環境配置 ENV_OPTS="--spring.profiles.active=release" SPRING_CONFIG_LOCATION="--spring.config.location=$APP_HOME/release/job.properties,$APP_HOME/release/application.properties,$APP_HOME/release/quartz.properties" #端口號 SERVER_PORT="8085" #java虛擬機啟動參數 JAVA_OPTS="-ms512m -mx512m -Xmn256m -Djava.awt.headless=true -XX:MaxPermSize=128m -Dsun.net.http.allowRestrictedHeaders=true" ################################### # 獲取進程id pid=0 checkpid() { server_pid=$(pgrep -f $JAR_FILE) if [ -n "$server_pid" ]; then pid=`echo $server_pid` else pid=0 fi } start(){ echo "ready to start $JAR_FILE" checkpid if [ 0 -ne $pid ] then echo "warn: server started already!" else java $JAVA_OPS -jar $JAR_FILE --server.port=$SERVER_PORT $SPRING_CONFIG_LOCATION > stdout.log & sleep 3s if [ 0 -ne $pid ] then echo "warining: failed" else echo "server started" fi fi } stop(){ checkpid if [ 0 -ne $pid ] then kill -9 $pid checkpid if [ 0 -eq $pid ] then echo "server stoped" else echo "warning: server toped failed!" fi else echo ‘warning: server not started!‘ fi } case $1 in start) start ;; restart) stop start ;; stop) stop ;; esac
linux 部署腳本