提交 291c25aa 编写于 作者: sq3536's avatar sq3536

Merge remote-tracking branch 'origin/master'

......@@ -37,12 +37,10 @@
git clone -b master $para2 ibzdst/
export NODE_OPTIONS=--max-old-space-size=4096
cd ibzdst/
mvn clean package -Papi
mvn install -Papi
mvn clean package -Papi-war
cd ibzdst-provider/ibzdst-provider-api
mvn -Papi docker:build
mvn -Papi docker:push
docker -H $para1 stack deploy --compose-file=src/main/docker/ibzdst-provider-api.yaml ibzlab-rt --with-registry-auth
mvn -Papi-war exec:exec@prepare
mvn -Papi-war exec:exec@buildpush
</command>
</hudson.tasks.Shell>
</builders>
......
FROM adoptopenjdk/openjdk8:jdk8u242-b08-centos
FROM image.ibizlab.cn/library/openjdk:8-jre-alpine
ENV TZ=Asia/Shanghai \
SPRING_OUTPUT_ANSI_ENABLED=ALWAYS \
......
......@@ -12,6 +12,7 @@
<artifactId>ibzdst-boot</artifactId>
<name>Ibzdst Dev Monolithic Boot</name>
<description>Ibzdst Boot</description>
<packaging>${project.packaging}</packaging>
<dependencies>
<dependency>
......@@ -64,6 +65,10 @@
</dependency>
</dependencies>
<properties>
<project.packaging>jar</project.packaging>
</properties>
<!--由于boot是通过dependency来关联所有子项目,页面和配置等信息都存在与子项目中,
所以您在对boot进行打包前,需要先将子项目install到maven仓库,以确保boot可以正常引用所有完整的子项目-->
<profiles>
......@@ -117,6 +122,62 @@
</plugins>
</build>
</profile>
<profile>
<id>boot-war</id>
<properties>
<project.packaging>war</project.packaging>
</properties>
<build>
<resources>
<resource>
<directory>${basedir}/src/main/resources</directory>
<includes>
<include>**/**</include>
</includes>
</resource>
</resources>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<finalName>ibzdst</finalName>
<jvmArguments>-Dfile.encoding=UTF-8</jvmArguments>
<mainClass>cn.ibizlab.DevBootApplication</mainClass>
<outputDirectory>../</outputDirectory>
</configuration>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>com.spotify</groupId>
<artifactId>docker-maven-plugin</artifactId>
<version>0.4.13</version>
<configuration>
<serverId>ibiz-dev</serverId>
<imageName>ibiz4j/ibizlab-dst:latest</imageName>
<dockerDirectory>${project.basedir}/src/main/docker</dockerDirectory>
<resources>
<resource>
<targetPath>/</targetPath>
<directory>../</directory>
<include>ibzdst.war</include>
</resource>
</resources>
</configuration>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>
package cn.ibizlab;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
/**
* 提供外部容器启动服务能力
*/
@Slf4j
public class DevBootInitializer extends SpringBootServletInitializer {
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) {
log.info("--正在使用外部容器启动服务--");
return builder.sources(DevBootApplication.class);
}
}
package cn.ibizlab.core.util.config;
import com.alibaba.cloud.nacos.registry.NacosAutoServiceRegistration;
import cn.ibizlab.util.errors.BadRequestAlertException;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.stereotype.Component;
import org.springframework.util.ObjectUtils;
import org.springframework.util.StringUtils;
import javax.management.MBeanServer;
import javax.management.ObjectName;
import javax.management.Query;
import java.lang.management.ManagementFactory;
import java.util.Set;
/**
* 外部容器启动服务时,自动注册服务到nacos
*/
@Component
@Slf4j
public class NacosRegisterConfig implements ApplicationRunner {
@Autowired(required = false)
private NacosAutoServiceRegistration registration;
@Value("${server.port:8080}")
Integer port;
@Override
public void run(ApplicationArguments args) {
log.info("正在尝试将应用程序注册到nacos");
if (registration != null && port != null) {
try {
String containerPort = getContainerPort();
if(!StringUtils.isEmpty(containerPort)){
registration.setPort(new Integer(containerPort));
}
else{
registration.setPort(port);
log.info("无法获取外部容器端口,将使用程序默认端口{}",port);
}
registration.start();
} catch (Exception e) {
throw new BadRequestAlertException("应用程序注册到nacos失败,"+e,"","");
}
log.info("已将应用程序成功注册到nacos");
}
else{
log.info("无法获取应用程序端口,将应用程序注册到nacos请求被忽略。");
}
}
/**
* 获取外部容器端口
*/
public String getContainerPort(){
String port = null;
try {
MBeanServer beanServer = ManagementFactory.getPlatformMBeanServer();
Set<ObjectName> objectNames = beanServer.queryNames(new ObjectName("*:type=Connector,*"), Query.match(Query.attr("protocol"), Query.value("HTTP/1.1")));
if(!ObjectUtils.isEmpty(objectNames)){
port = objectNames.iterator().next().getKeyProperty("port");
}
}
catch (Exception e) {
log.error("获取外部容器端口失败!"+e);
}
return port;
}
}
package cn.ibizlab.core.util.config;
import org.springframework.boot.autoconfigure.condition.ConditionalOnExpression;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.Configuration;
import com.baomidou.jobs.starter.EnableJobs;
@ConditionalOnExpression("!'${jobs.admin-address:NA}'.equals('NA')")
//@ConditionalOnExpression("!'${jobs.admin-address:NA}'.equals('NA')")
@ConditionalOnProperty(name = "jobs.enabled", havingValue = "true", matchIfMissing = false)
@EnableJobs
@Configuration
public class XxlJobConfig {
......
{
"systemid":"ibzdst",
"systemname":"ibzdst",
"unires":[
],
"entities":[
......
......@@ -83,6 +83,8 @@
<!-- 阿里seata分布式事务 -->
<alibaba-seata.version>1.3.0</alibaba-seata.version>
<log4j2.version>2.16.0</log4j2.version>
<oracle.version>19.8.0.0</oracle.version>
<postgresql.version>42.2.6</postgresql.version>
<flowable-modeler.version>6.4.2</flowable-modeler.version>
......
FROM adoptopenjdk/openjdk8:jdk8u242-b08-centos
FROM image.ibizlab.cn/library/openjdk:8-jre-alpine
ENV TZ=Asia/Shanghai \
SPRING_OUTPUT_ANSI_ENABLED=ALWAYS \
......
......@@ -46,6 +46,8 @@ spec:
value: "com.mysql.jdbc.Driver"
- name: SPRING_DATASOURCE_DEFAULTSCHEMA
value: "a_A_5d9d78509"
- name: IBIZ_DEPLOY_PACKAGETYPE
value: "war"
- name: NACOS
value: "172.16.100.243:8848"
- name: SPRING_CLOUD_NACOS_DISCOVERY_GROUP
......
......@@ -6,6 +6,12 @@ services:
- "40011:40011"
networks:
- agent_network
logging:
driver: loki
options:
loki-url: "http://172.16.240.111:3100/loki/api/v1/push"
max-size: "50m"
max-file: "10"
environment:
- SPRING_CLOUD_NACOS_DISCOVERY_IP=172.16.180.237
- SERVER_PORT=40011
......@@ -18,6 +24,7 @@ services:
- SPRING_DATASOURCE_URL=jdbc:mysql://172.16.180.232:3306/a_A_5d9d78509?autoReconnect=true&useUnicode=true&characterEncoding=UTF-8&useOldAliasMetadataBehavior=true&allowMultiQueries=true&serverTimezone=GMT%2B8
- SPRING_DATASOURCE_DRIVER-CLASS-NAME=com.mysql.jdbc.Driver
- SPRING_DATASOURCE_DEFAULTSCHEMA=a_A_5d9d78509
- IBIZ_DEPLOY_PACKAGETYPE=war
- NACOS=172.16.100.243:8848
- SPRING_CLOUD_NACOS_DISCOVERY_GROUP=ibizdev
deploy:
......
package cn.ibizlab.api;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
/**
* 提供外部容器启动服务能力
*/
@Slf4j
public class ibzdstapiInitializer extends SpringBootServletInitializer {
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) {
log.info("--正在使用外部容器启动服务--");
return builder.sources(ibzdstapiApplication.class);
}
}
......@@ -3,4 +3,9 @@ server:
#Log配置
logging:
level:
cn.ibizlab: info
\ No newline at end of file
cn.ibizlab: info
## jobs
jobs:
app-port: 9999
enabled: true
\ No newline at end of file
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册