zoukankan      html  css  js  c++  java
  • linux下的springboot项目启动文件

    启动springboot项目的脚本文件,启动时./startup.sh即可,会先关闭原进程,再启一个新进程。

    创建startup.sh

    写入内容

     #!/bin/bash

    clear  

    echo ""

    echo "*******************************************************************************************"

    echo "****************************Welcome using the Automated scripts****************************"

    echo "*******************************************************************************************"

    echo ""

    echo ""

    echo "     ->1|restart test-project          **********        "

    echo ""

    echo "     ->5|restart all project"

    echo ""

    echo "*******************************************************************************************"

    echo ""

    JAVA_HOME=/usr/local/jdk1.8.0_121

    JRE_HOME=/usr/local/jdk1.8.0_121/jre

    PATH=$PATH:$JAVA_HOME/bin:$JRe_HOME/bin:$TOMCAT_HOME/bin

    CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar:$JRE_HOME/lib

    export JAVA_HOME JRE_HOME PATH CLASSPATH

    #restart test-project

    restartApiv3 () {

        pid=`ps aux | grep test-project-0.1.jar | grep -v grep  | awk '{print $2}'`

        echo $pid

        if [ -n "$pid" ]

            then {

                echo "========kill test-project begin=============="

                echo $pid

                kill -9 $pid

                echo "========kill test-project end=============="

                sleep 2

            }

        fi

        echo "===========startup test-project=============="

        cd /data/www/test/  #jar所在路径

        nohup java -jar -Dspring.profiles.active=qa -Xms256m -Xmx1g /data/www/test/test-project-0.1.jar --server.port=8089 >> /dev/null &    #--server.port=8089这个是动态设置端口,也可不写就会按配置里写的端口

        sleep 12

        pid=`ps aux | grep test-project-0.1.jar | grep -v grep  | awk '{print $2}'`

        echo $pid

        if [ -n "$pid" ]

            then {

                 echo " test-project started "

                 return 0

            }

        else

            return 1

        fi

    }

    if [ "$1" != "" ] ; then

        if [ $1 == 1 ] ; then

            restartApiv3

            exit $?

        elif [ $1 == 5 ] ; then

            restartApiv3

            exit $?

        else

            echo "选择有误,再见!~"

        fi

    else

        read -p "Enter index number to select: " 

        if [ "${REPLY}" == 1 ] ; then

            restartApiv3

        elif [ "${REPLY}" == 5 ] ; then

            restartApiv3

        else

            echo "选择有误,再见!"

      fi

    fi

  • 相关阅读:
    腾讯云搭建web环境基础指导
    php正则表达式填坑
    微信小程序新手填坑
    如何优雅的扒网站——工具篇
    两个常见的前端问题:如何让分页码居中显示 及 解决浮动元素覆盖的问题
    非常全面的PHP header函数设置HTTP头的示例
    Nginx + fastcgi + php 的原理与关系
    Linux命令之 tar
    数据结构和算法
    单例模式
  • 原文地址:https://www.cnblogs.com/ggooo/p/8580282.html
Copyright © 2011-2022 走看看