zoukankan      html  css  js  c++  java
  • Jar后台运行脚本 window-bat/unix-sh for springboot

    springboot项目,直接打包成jar

    自带tomcat,可以通过java命令直接运行,无需web应用服务.

    以maven为例,在pom.xml中配置打包输出类型:

    <packaging>jar</packaging>

    配置build:

    <build>
    <plugins>
    <plugin>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-maven-plugin</artifactId>
    </plugin>
    </plugins>
    </build>

    打包成jar后,可以通过批处理直接启动或者停止.

    window-bat

    start:

    @echo off
    :wmic process where "commandline like '%%-jar reportcheck%%'" call terminate
    set path=C:Program FilesJavajre1.8.0_91in
    START "reportcheck" "%path%javaw" -jar reportcheck-0.0.1-SNAPSHOT.jar
    pause

    stop:

    @echo off
    wmic process where "commandline like '%%-jar reportcheck%%'" call terminate
    pause

    unix-sh

    start:

    #!/bin/bash
    if ps aux | grep -v 'grep' | grep 'java' | grep 'reportcheck.jar'
    then
    pid=$(ps aux | grep -v 'grep' |grep 'java'|grep 'reportcheck.jar'| awk '{print $2}');
    echo pid;
    kill -9 ${pid};
    echo old reportcheck exit...;
    fi
    nohup java -jar reportcheck.jar &> out &
    echo reportcheck running...

    stop:

    #!/bin/bash
    if ps aux | grep -v 'grep' | grep 'java' | grep 'reportcheck.jar'
    then
    pid=$(ps aux | grep -v 'grep' |grep 'java'|grep 'reportcheck.jar'| awk '{print $2}');
    echo pid
    kill -9 ${pid};
    fi
  • 相关阅读:
    Helm安装带验证的ElasticSearch 6.x 7.x 集群
    K8S权限控制,限制用户在多个namespace上的访问权限
    Helm安装spinnaker到k8s集群
    离线安装spinnaker到K8S集群
    Kubernetes之CronJob
    GO语言GIN框架入门
    Kubernetes kubectl 命令概述
    Kubernetes Service
    Kubernetes Ingress
    centos+Jenkins+maven搭建持续集成
  • 原文地址:https://www.cnblogs.com/ylpb/p/9146184.html
Copyright © 2011-2022 走看看