Commit abd75aa8 by wangguangchao

修改打包方式

parent 137ac685
......@@ -17,8 +17,9 @@ spec:
version: v1
spec:
containers:
- image: 192.168.0.110:8062/rdwh/eurekaserver:latest
- image: rdwh/eurekaserver:latest
name: eureka-server
command: ['sh','-c','sh ./bin/startup.sh && sleep 3600']
ports:
- containerPort: 8769
---
......
......@@ -35,6 +35,40 @@
</dependency>
</dependencies>
<profiles>
<profile>
<id>local</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<properties>
<package.environment>local</package.environment>
<jar.version>-SNAPSHOT</jar.version>
</properties>
</profile>
<profile>
<id>dev</id>
<properties>
<package.environment>dev</package.environment>
<jar.version>-SNAPSHOT</jar.version>
</properties>
</profile>
<profile>
<id>test</id>
<properties>
<package.environment>test</package.environment>
<jar.version>-TEST</jar.version>
</properties>
</profile>
<profile>
<id>prd</id>
<properties>
<package.environment>prd</package.environment>
<jar.version>-RELEASE</jar.version>
</properties>
</profile>
</profiles>
<repositories>
<repository>
<id>brilliance-virtual</id>
......@@ -48,17 +82,77 @@
<build>
<plugins>
<!-- <plugin>-->
<!-- <groupId>org.springframework.boot</groupId>-->
<!-- <artifactId>spring-boot-maven-plugin</artifactId>-->
<!-- <version>2.3.12.RELEASE</version>-->
<!-- <executions>-->
<!-- <execution>-->
<!-- <goals>-->
<!-- <goal>repackage</goal>-->
<!-- </goals>-->
<!-- </execution>-->
<!-- </executions>-->
<!-- </plugin>-->
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>2.3.12.RELEASE</version>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>3.1.1</version>
<executions>
<execution>
<id>copy-dependencies</id>
<phase>package</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<outputDirectory>${project.build.directory}/lib/</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>3.1.1</version>
<configuration>
<excludes>
<exclude>*.**</exclude>
<exclude>*/*.xml</exclude>
<exclude>config/**</exclude>
</excludes>
<archive>
<manifest>
<addClasspath>true</addClasspath>
<classpathPrefix>lib/</classpathPrefix>
<useUniqueVersions>false</useUniqueVersions>
<mainClass>com.brilliance.hk.EurekaServerApplication</mainClass>
</manifest>
</archive>
<outputDirectory>${project.build.directory}</outputDirectory>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<version>3.1.1</version>
<executions>
<execution>
<id>make-assembly</id>
<phase>package</phase>
<goals>
<goal>repackage</goal>
<goal>single</goal>
</goals>
</execution>
</executions>
<configuration>
<attach>true</attach>
<appendAssemblyId>false</appendAssemblyId>
<tarLongFileMode>gnu</tarLongFileMode>
<descriptors>
<descriptor>src/main/assembly/assembly.xml</descriptor>
</descriptors>
</configuration>
</plugin>
</plugins>
</build>
......
<assembly xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/assembly-1.0.0.xsd">
<id>package</id>
<formats>
<format>zip</format>
</formats>
<includeBaseDirectory>false</includeBaseDirectory>
<fileSets>
<!-- 程序本身的jar -->
<fileSet>
<directory>target</directory>
<outputDirectory>.</outputDirectory>
<includes>
<include>${project.artifactId}*.jar</include>
</includes>
</fileSet>
<!-- 将第三方依赖打包到lib目录中 -->
<fileSet>
<directory>${basedir}/target/lib</directory>
<outputDirectory>lib</outputDirectory>
</fileSet>
<!-- 内置boot模块配置文件的外置 -->
<fileSet>
<directory>src/main/resources</directory>
<outputDirectory>config</outputDirectory>
<includes>
<include>**</include>
</includes>
</fileSet>
<!-- 程序的启动脚本 -->
<fileSet>
<directory>src/main/scripts</directory>
<includes>
<include>*.sh</include>
<include>*.bat</include>
</includes>
<outputDirectory>bin</outputDirectory>
<lineEnding>unix</lineEnding>
<fileMode>0755</fileMode>
</fileSet>
<!-- 多环境配置文件 -->
<fileSet>
<directory>src/main/profiles/${package.environment}</directory>
<outputDirectory>config</outputDirectory>
<includes>
<include>**</include>
</includes>
</fileSet>
</fileSets>
</assembly>
eureka:
client:
fetch-registry: false
register-with-eureka: false
logging:
config: config/logback.xml
server:
port: 8769
spring:
application:
name: eureka
eureka:
client:
fetch-registry: false
register-with-eureka: false
logging:
config: classpath:logback.xml
server:
port: 8769
spring:
application:
name: eureka
#!/bin/sh
PRG="$0"
APP_WRK_HOME=`dirname "$PRG"`/..
APP_WRK_HOME=`cd "$APP_WRK_HOME" && pwd`
sh $APP_WRK_HOME/bin/shutdown.sh
#!/bin/bash
# ANSI Colors
echoRed() { echo $'\e[0;31m'"$1"$'\e[0m'; }
echoGreen() { echo $'\e[0;32m'"$1"$'\e[0m'; }
echoYellow() { echo $'\e[0;33m'"$1"$'\e[0m'; }
#启动脚本的主目录
PRG="$0"
APP_WRK_HOME=`dirname "$PRG"`/..
APP_WRK_HOME=`cd "$APP_WRK_HOME" && pwd`
#应用名
export APP_NAME=EUREKA-SERVER
psid=0
#检查进程ID
checkpid() {
if [[ -f $APP_WRK_HOME/bin/$APP_NAME.pid ]]; then
psid=$(cat $APP_WRK_HOME/bin/$APP_NAME.pid)
if [[ 0 -eq $(ps -ef |grep $psid |grep -v "grep" |wc -l) ]]; then
psid=0
fi
fi
}
#停止进程
dostop() {
checkpid
if [[ $psid -eq 0 ]]; then
echoYellow "warn: $APP_NAME pid was not found, can not be stopped!"
else
kill -9 $psid
rm -rf $APP_WRK_HOME/bin/$APP_NAME.pid
echoGreen "$APP_NAME stopped successfully! (pid=$psid)"
fi
}
dostop
exit 0
\ No newline at end of file
@echo off
@setlocal
REM set JUP SERVICE HOME
set "APP_WRK_HOME=%~dp0"
set "APP_WRK_HOME=%APP_WRK_HOME:~0,-4%"
set "APP_NAME=EUREKA-SERVER"
REM find boot jar file path
for %%i in (%APP_WRK_HOME%/*.jar) do set BOOT_JAR=%%i
set "JAVACMD=%JAVA_HOME%/bin/java.exe"
REM set "JAVA_OPTS=%JAVA_OPTS% -Xms512m -Xmx512m"
set "JAVA_OPTS=%JAVA_OPTS% -Dlogging.path=%APP_WRK_HOME%"
set "JAVA_OPTS=%JAVA_OPTS% -Dlogging.file=%APP_WRK_HOME%/logs/application.log"
rem the file skywalking-agent.jar is used at the link to track.
rem When deploying, please follow the actural situation to modify the path or version and modify the agent.config configuration file in agent/config.
rem Please refer to the configuration document to modify the contents of the configuration item collector.backend_service in agent.config
rem set "JAVA_OPTS=%JAVA_OPTS% -javaagent:d:/jup/services/JavaUnifiedPlatform_APM_Center_0.4-RELEASE/agent/skywalking-agent.jar"
rem set "JAVA_OPTS=%JAVA_OPTS% -DSW_AGENT_NAME=HK-BUSINESS"
set "JAVA_OPTS=%JAVA_OPTS% -server -Djava.net.preferIPv4Stack=true -Duser.timezone=Asia/Shanghai -Dclient.encoding.override=GBK -Dfile.encoding=GBK"
set "JAVA_OPTS=%JAVA_OPTS% -XX:+HeapDumpOnOutOfMemoryError"
REM execute
start "%APP_NAME%" "%JAVACMD%" %JAVA_OPTS% -jar %BOOT_JAR%
\ No newline at end of file
#!/bin/bash
# ANSI Colors
echoRed() { echo $'\e[0;31m'"$1"$'\e[0m'; }
echoGreen() { echo $'\e[0;32m'"$1"$'\e[0m'; }
echoYellow() { echo $'\e[0;33m'"$1"$'\e[0m'; }
#启动脚本的主目录
PRG="$0"
ENV="$1"
APP_WRK_HOME=`dirname "$PRG"`/..
APP_WRK_HOME=`cd "$APP_WRK_HOME" && pwd`
#应用名
export APP_NAME=EUREKA-SERVER
psid=0
#检查进程ID
checkpid() {
if [[ -f $APP_WRK_HOME/bin/$APP_NAME.pid ]]; then
psid=$(cat $APP_WRK_HOME/bin/$APP_NAME.pid)
if [[ -n $psid ]] && [[ 0 -eq $(ps -ef |grep $psid |grep -v "grep" |wc -l) ]]; then
psid=0
fi
fi
}
#启动进程
dostart() {
checkpid
if [[ $psid -ne 0 ]]; then
echoYellow "warn: $APP_NAME already started! (pid=$psid)"
else
export JAVA_OPTS="$JAVA_OPTS -Dlogging.path=$APP_WRK_HOME"
export JAVA_OPTS="$JAVA_OPTS -Dspring.profiles.active=$ENV"
export JAVA_OPTS="$JAVA_OPTS -server -Djava.net.preferIPv4Stack=true -Duser.timezone=Asia/Shanghai -Dclient.encoding.override=UTF-8 -Dfile.encoding=UTF-8 -Djava.security.egd=file:/dev/./urandom"
export JAVA_OPTS="$JAVA_OPTS -XX:+HeapDumpOnOutOfMemoryError"
export JAVA_OPTS="$JAVA_OPTS -Xms512m -Xmx2048m"
export JAVA_OPTS="$JAVA_OPTS -Dlogging.file=$APP_WRK_HOME/logs/application.log"
BOOT_JAR=`echo $APP_WRK_HOME/*.jar`
nohup java $JAVA_OPTS -jar $BOOT_JAR > /dev/null 2>&1 &
echo "$!" > $APP_WRK_HOME/bin/$APP_NAME.pid
sleep 2
checkpid
if [[ $psid -ne 0 ]]; then
echoGreen "$APP_NAME successful started! (pid=$psid)"
else
echoRed "$APP_NAME started failed!"
fi
fi
}
dostart
exit 0
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment