wanghc
2023-06-27 933ee70c42092a600696428cefd178de805d0439
打包方式修改为lib,添加启动脚本
5 files added
2 files modified
380 ■■■■ changed files
cmci-pfcs-gateway/pom.xml 165 ●●●● patch | view | raw | blame | history
cmci-pfcs-gateway/src/main/resources/application.properties 2 ●●● patch | view | raw | blame | history
cmci-pfcs-gateway/src/main/resources/bin/restart.sh 39 ●●●●● patch | view | raw | blame | history
cmci-pfcs-gateway/src/main/resources/bin/service.sh 89 ●●●●● patch | view | raw | blame | history
cmci-pfcs-gateway/src/main/resources/bin/shutdown.sh 40 ●●●●● patch | view | raw | blame | history
cmci-pfcs-gateway/src/main/resources/bin/start.bat 8 ●●●●● patch | view | raw | blame | history
cmci-pfcs-gateway/src/main/resources/bin/startup.sh 37 ●●●●● patch | view | raw | blame | history
cmci-pfcs-gateway/pom.xml
@@ -77,57 +77,128 @@
        </resources>
        <plugins>
            <!-- 打包jar文件时,配置manifest文件,加入lib包的jar依赖 -->
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
            <!-- docker 镜像生成 -->
            <plugin>
                <groupId>com.spotify</groupId>
                <artifactId>docker-maven-plugin</artifactId>
                <version>1.2.0</version>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-jar-plugin</artifactId>
                <configuration>
                    <!-- 镜像名 -->
                    <imageName>${project.artifactId}</imageName>
                    <!-- Dockerfile所在目录 -->
                    <dockerDirectory>${project.basedir}/src/main/docker</dockerDirectory>
                    <!-- 生成的jar文件 -->
                    <buildArgs>
                        <JAR_FILE>${project.build.finalName}.jar</JAR_FILE>
                    </buildArgs>
                    <!-- 复制jar到docker容器指定目录 -->
                    <resources>
                        <resource>
                            <targetPath>/</targetPath>
                            <directory>${project.build.directory}</directory>
                            <include>${project.build.finalName}.jar</include>
                        </resource>
                    </resources>
                    <classesDirectory>target/classes/</classesDirectory>
                    <archive>
                        <manifest>
                            <mainClass>boot.Application</mainClass>
                            <!-- 打包时 MANIFEST.MF文件不记录的时间戳版本 -->
                            <useUniqueVersions>false</useUniqueVersions>
                            <addClasspath>true</addClasspath>
                            <classpathPrefix>lib/</classpathPrefix>
                        </manifest>
                        <manifestEntries>
                            <Class-Path>.</Class-Path>
                        </manifestEntries>
                    </archive>
                </configuration>
            </plugin>
            <!-- wsdl生成插件 生成了就不用了 这里注释掉 -->
<!--            <plugin>-->
<!--                <groupId>org.apache.cxf</groupId>-->
<!--                <artifactId>cxf-codegen-plugin</artifactId>-->
<!--                <version>3.5.1</version>-->
<!--                <executions>-->
<!--                    <execution>-->
<!--                        <id>generate-sources</id>-->
<!--                        <phase>generate-sources</phase>-->
<!--                        <configuration>-->
<!--                            &lt;!&ndash; xml文件 &ndash;&gt;-->
<!--                            <sourceRoot>src/main/java</sourceRoot>-->
<!--                            <wsdlRoot>${basedir}/src/main/resources/wsdl</wsdlRoot>-->
<!--                            <includes>-->
<!--                                <include>*.wsdl</include>-->
<!--                            </includes>-->
<!--                        </configuration>-->
<!--                        <goals>-->
<!--                            <goal>wsdl2java</goal>-->
<!--                        </goals>-->
<!--                    </execution>-->
<!--                </executions>-->
<!--            </plugin>-->
            <plugin>
                <artifactId>maven-resources-plugin</artifactId>
                <executions>
                    <execution>
                        <id>copy-resources-bin</id>
                        <phase>validate</phase>
                        <goals>
                            <goal>copy-resources</goal>
                        </goals>
                        <configuration>
                            <outputDirectory>${project.build.directory}/bin</outputDirectory>
                            <resources>
                                <resource>
                                    <directory>src/main/resources/bin</directory>
                                    <filtering>true</filtering>
                                </resource>
                            </resources>
                        </configuration>
                    </execution>
                    <execution>
                        <id>copy-resources-html5</id>
                        <phase>validate</phase>
                        <goals>
                            <goal>copy-resources</goal>
                        </goals>
                        <configuration>
                            <outputDirectory>${project.build.directory}/html5</outputDirectory>
                            <resources>
                                <resource>
                                    <directory>src/main/resources/html5</directory>
                                    <filtering>true</filtering>
                                </resource>
                            </resources>
                        </configuration>
                    </execution>
                    <execution>
                        <id>copy-resources-static</id>
                        <phase>validate</phase>
                        <goals>
                            <goal>copy-resources</goal>
                        </goals>
                        <configuration>
                            <outputDirectory>${project.build.directory}/static</outputDirectory>
                            <resources>
                                <resource>
                                    <directory>src/main/resources/static</directory>
                                    <filtering>true</filtering>
                                </resource>
                            </resources>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-dependency-plugin</artifactId>
                <executions>
                    <execution>
                        <id>copy-dependencies</id>
                        <phase>package</phase>
                        <goals>
                            <goal>copy-dependencies</goal>
                        </goals>
                        <configuration>
                            <type>jar</type>
                            <includeTypes>jar</includeTypes>
                            <outputDirectory>
                                ${project.build.directory}/lib
                            </outputDirectory>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <dependencies>
                    <dependency>
                        <groupId>org.apache.maven.surefire</groupId>
                        <artifactId>surefire-junit47</artifactId>
                        <version>2.12</version>
                    </dependency>
                </dependencies>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration>
                    <source>1.7</source>
                    <target>1.7</target>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <configuration>
                    <skip>true</skip>
                </configuration>
            </plugin>
        </plugins>
    </build>
cmci-pfcs-gateway/src/main/resources/application.properties
@@ -1,4 +1,4 @@
spring.application.name=@pom.artifactId@
server.port=8400
server.port=60789
server.servlet.context-path=/pf-api
logging.config=classpath:logback.xml
cmci-pfcs-gateway/src/main/resources/bin/restart.sh
New file
@@ -0,0 +1,39 @@
#!/bin/sh
echo "***************************开始重启************************"
os400=false
case "`uname`" in
OS400*) os400=true;;
esac
# resolve links - $0 may be a softlink
PRG="$0"
while [ -h "$PRG" ] ; do
  ls=`ls -ld "$PRG"`
  link=`expr "$ls" : '.*-> \(.*\)$'`
  if expr "$link" : '/.*' > /dev/null; then
    PRG="$link"
  else
    PRG=`dirname "$PRG"`/"$link"
  fi
done
PRGDIR=`dirname "$PRG"`
EXECUTABLE=service.sh
# Check that target executable exists
if $os400; then
  # -x will Only work on the os400 if the files are:
  # 1. owned by the user
  # 2. owned by the PRIMARY group of the user
  # this will not work if the user belongs in secondary groups
  eval
else
  if [ ! -x "$PRGDIR"/"$EXECUTABLE" ]; then
    echo "没有找到 $PRGDIR/$EXECUTABLE"
    echo "没有执行权限"
    exit 1
  fi
fi
exec "$PRGDIR"/"$EXECUTABLE" restart "$@"
echo "***************************服务重启************************"
cmci-pfcs-gateway/src/main/resources/bin/service.sh
New file
@@ -0,0 +1,89 @@
#!/bin/sh
## java env
export JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.262.b10-1.el7.x86_64
export JRE_HOME=$JAVA_HOME/jre
## you just need to change this param name
SERVICE_NAME=cmci-pfcs-gateway
SERVICE_DIR=/home/fenl/springboot/$SERVICE_NAME
JAR_NAME=$SERVICE_DIR/$SERVICE_NAME\.jar
PID=$SERVICE_NAME\.pid
cd $SERVICE_DIR
LOGS_DIR=/home/fenl/logs/cmci_pfcs_gateway_web
if [ ! -d $LOGS_DIR ]; then
    mkdir $LOGS_DIR
fi
STDOUT_FILE=$LOGS_DIR/cmci_pfcs_gateway_web.log
case "$1" in
    start)
        nohup java -server -Xms256M -Xmx512M  -Xss512k -XX:+AggressiveOpts -XX:+UseBiasedLocking -XX:PermSize=128M -XX:MaxPermSize=256M -XX:+DisableExplicitGC -XX:MaxTenuringThreshold=15 -XX:+UseConcMarkSweepGC -XX:+UseParNewGC  -XX:+CMSParallelRemarkEnabled -XX:+UseCMSCompactAtFullCollection -XX:LargePageSizeInBytes=128m  -XX:+UseFastAccessorMethods -XX:+UseCMSInitiatingOccupancyOnly -Djava.awt.headless=true -Duser.timezone=GMT+8 -jar $JAR_NAME >/dev/null 2>nohup.out &
        echo $! > $SERVICE_DIR/$PID
        echo " ……………………………………………………………………………………"
        echo ""
        echo "╭⌒╮成功━┅~ ¤  ╭⌒╮ ╭⌒╮ "
        echo "╭⌒╭⌒╮╭⌒╮~╭⌒╮︶︶, ︶︶ "
        echo ",︶︶︶︶,''︶~~ ,''~︶︶  ,'' "
        echo "╱◥█◣ ╱◥█◣ "
        echo "︱田︱田︱︱田︱田︱ "
        echo "╬╬╬╬╬╬╬╬╬╬╬╬╬╬ "
        echo ""
        echo "……………………………………………………………………………………"
        ;;
    stop)
        kill `cat $SERVICE_DIR/$PID`
        rm -rf $SERVICE_DIR/$PID
        echo "********************* stop $SERVICE_NAME  ******************"
        sleep 5
        P_ID=`ps -ef | grep -w "$SERVICE_NAME" | grep -v "grep" | awk '{print $2}'`
        if [ "$P_ID" == "" ]; then
            echo "********************* $SERVICE_NAME process not exists or stop success"
        else
            echo "********************* $SERVICE_NAME process pid is:$P_ID"
            echo "                              .======."
            echo "                              | INRI |"
            echo "                              |      |"
            echo "                     .========'      '========."
            echo "                     |       $SERVICE_NAME    |"
            echo "                     '========. \   / ========'"
            echo "                              | |  / |"
            echo "                              |/-.(  |"
            echo "                              |\_._\ |"
            echo "                              | \ \ ;|"
            echo "                              |  > |/|"
            echo "                              | / // |"
            echo "                              | |//  |"
            echo "                              | \(\  |"
            echo "                              |      |"
            echo "                              |      |"
            echo "                  \\    _  _\\| \//  |//_   _ \// _"
            kill -9 $P_ID
        fi
        ;;
    restart)
        $0 stop
        sleep 2
        $0 start
        echo "*********************restart $SERVICE_NAME"
        ;;
    *)
        ## restart
        $0 stop
        sleep 2
        $0 start
        ;;
esac
exit 0
cmci-pfcs-gateway/src/main/resources/bin/shutdown.sh
New file
@@ -0,0 +1,40 @@
#!/bin/sh
echo "***************************开始优雅停止服务****************************"
os400=false
case "`uname`" in
OS400*) os400=true;;
esac
# resolve links - $0 may be a softlink
PRG="$0"
while [ -h "$PRG" ] ; do
  ls=`ls -ld "$PRG"`
  link=`expr "$ls" : '.*-> \(.*\)$'`
  if expr "$link" : '/.*' > /dev/null; then
    PRG="$link"
  else
    PRG=`dirname "$PRG"`/"$link"
  fi
done
PRGDIR=`dirname "$PRG"`
EXECUTABLE=service.sh
# Check that target executable exists
if $os400; then
  # -x will Only work on the os400 if the files are:
  # 1. owned by the user
  # 2. owned by the PRIMARY group of the user
  # this will not work if the user belongs in secondary groups
  eval
else
  if [ ! -x "$PRGDIR"/"$EXECUTABLE" ]; then
    echo "Cannot find $PRGDIR/$EXECUTABLE"
    echo "The file is absent or does not have execute permission"
    echo "This file is needed to run this program"
    exit 1
  fi
fi
exec "$PRGDIR"/"$EXECUTABLE" stop "$@"
echo "**************************服务优雅停止****************************"
cmci-pfcs-gateway/src/main/resources/bin/start.bat
New file
@@ -0,0 +1,8 @@
@echo off
set PATH=C:\Program Files\Java\jdk1.7.0_79\bin;C:\WINDOWS;C:\WINDOWS\COMMAND
set classpath=.;C:\Program Files\Java\jdk1.7.0_79\lib\tools.jar;C:\Program Files\Java\jdk1.7.0_79\lib\dt.jar
cd..
java -Xmx128m -Xms64m -Xmn32m -Xss16m  -jar commerce-app--gateway.jar
pause
cmci-pfcs-gateway/src/main/resources/bin/startup.sh
New file
@@ -0,0 +1,37 @@
#!/bin/sh
os400=false
case "`uname`" in
OS400*) os400=true;;
esac
PRG="$0"
while [ -h "$PRG" ] ; do
  ls=`ls -ld "$PRG"`
  link=`expr "$ls" : '.*-> \(.*\)$'`
  if expr "$link" : '/.*' > /dev/null; then
    PRG="$link"
  else
    PRG=`dirname "$PRG"`/"$link"
  fi
done
PRGDIR=`dirname "$PRG"`
EXECUTABLE=service.sh
# Check that target executable exists
if $os400; then
  # -x will Only work on the os400 if the files are:
  # 1. owned by the user
  # 2. owned by the PRIMARY group of the user
  # this will not work if the user belongs in secondary groups
  eval
else
  if [ ! -x "$PRGDIR"/"$EXECUTABLE" ]; then
    echo "Cannot find $PRGDIR/$EXECUTABLE"
    echo "The file is absent or does not have execute permission"
    echo "This file is needed to run this program"
    exit 1
  fi
fi
exec "$PRGDIR"/"$EXECUTABLE" start "$@"