• linux springboot快捷启动脚本


    yum install redhat-lsb -y

     

    进入/usr/local/bin
    放入脚本springboot
    添加权限
    chmod +x springboot

    ####################################

    #!/bin/bash
    . /etc/profile

    if [ -r /lib/lsb/init-functions ]; then
    . /lib/lsb/init-functions
    else
    exit 1
    fi

    NAME="$(basename $0)"

    function usage()
    {
    echo "Usage: $0 {start|stop|restart} {mkt-web|eshop-app}"
    RETVAL="2"
    }

    if [ $# -ne 2 ]; then
    usage
    exit 1
    fi

    APP=$2
    if [ -z $APP -o ! -d "/data/springboot/$APP" ];then
    echo "Null parameter or $APP not exists"
    exit 1
    fi

    SPRINGBOOT_HOME="/data/springboot/$APP"

    function start() {
    echo "Starting ${APP}: "
    if [ "$RETVAL" != "0" ];then
    log_failure_msg
    return
    fi

    pid=$(ps aux | grep "${SPRINGBOOT_HOME}" | grep -v "grep" | awk '{print $2}')
    if [ -n "$pid" ];then
    log_success_msg "is running, PID: $pid"
    return
    fi

    nohup java -jar ${SPRINGBOOT_HOME}/$APP.jar > ${SPRINGBOOT_HOME}/$APP.log 2>&1 &
    sleep 3
    pid=$(ps aux | grep "${SPRINGBOOT_HOME}" | grep -v "grep" | awk '{print $2}')
    if [ -z "$pid" ];then
    log_failure_msg
    RETVAL=1
    else
    log_success_msg "PID: $pid"
    fi
    }

    function stop() {
    echo -n "Stopping ${APP}: "

    pid=$(ps aux | grep "${SPRINGBOOT_HOME}" | grep -v grep | awk '{print $2}')
    if [ -z "$pid" ];then
    echo -n "not running"
    log_warning_msg
    return
    fi

    count=0
    until [ -z "$(ps aux | grep "${SPRINGBOOT_HOME}" | grep -v grep | awk '{print $2}')" ] || [ $count -gt 3 ];
    do
    kill -9 $pid
    sleep 3
    let count="${count}+1"
    done
    if [ $count -gt 3 ];then
    RETVAL=1
    log_failure_msg "PID: $pid"
    return 1
    else
    rm -rf /data/springboot/$APP/work/*
    rm -rf /data/springboot/$APP/temp/*
    log_success_msg "PID: $pid"
    fi
    }

    RETVAL="0"
    case "$1" in
    start)
    start
    ;;
    stop)
    stop
    ;;
    restart)
    stop
    start
    ;;
    *)
    usage
    ;;
    esac

    exit $RETVAL

    ####################################

    文件放置目录/data/springboot/$APP/$APP.jar

    启动命令:springboot start $APP

     

     

  • 相关阅读:
    java mybatis 新增记录 与 insertSelective 保存问题
    01 开发环境搭建
    2021年:系列文章总结
    在win10上安装MTK驱动(附驱动下载链接)
    Gerrit 大量代码提交流程优化
    mysqldump的使用
    配置 Gerrit 迁移
    解决:编译安卓源码时 JDK 报错 error='Not enough space' (errno=12)
    修改Git Commit提交记录的用户名Name和邮箱Email
    Android 各层架构
  • 原文地址:https://www.cnblogs.com/Nanaya/p/14030814.html
Copyright © 2020-2023  润新知