瀏覽代碼

优化dockerfile文件

zhangqiankun 3 年之前
父節點
當前提交
855ea140d2

+ 8 - 5
docker/Dockerfile

@@ -1,15 +1,18 @@
-#FROM openjdk:8-jdk-alpine 文件下载会出现空指针错误
-FROM java:8
+FROM registry.persagy.com/base/centos:v-jdk1.8
+ENV TZ=Asia/Shanghai
+ENV JAVA_OPTS -XX:+UseContainerSupport -XX:MaxRAMPercentage=75.0 -XX:InitialRAMPercentage=75.0 -XX:MinRAMPercentage=75.0
+RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezon
+#增加一个arthas的包,方便应用排查问题
+RUN yum install -y unzip zip wget telnet tzdata
+COPY --from=hengyunabc/arthas:latest /opt/arthas /opt/arthas
+
 ARG WORKER_HOME
-RUN apt-get install -y --no-install-recommends tzdata && rm -rf /var/lib/apt/lists/*
-RUN ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime	&& echo 'Asia/Shanghai' > /etc/timezone
 RUN mkdir -p $WORKER_HOME/config
 COPY *.jar $WORKER_HOME/
 COPY entrypoint.sh $WORKER_HOME/
 COPY *.yml $WORKER_HOME/config/
 COPY *.jks $WORKER_HOME/config/
 COPY *.json $WORKER_HOME/config/
-#EXPOSE 9931
 WORKDIR $WORKER_HOME
 RUN ls
 ENTRYPOINT ["sh","./entrypoint.sh"]

+ 1 - 1
docker/entrypoint.sh

@@ -1,4 +1,4 @@
 #!/bin/bash
 echo "entrypoint run..."
 #注意此处目录为 pipeline 中定义的目录
-java -jar -Xms2048m -Xmx2048m -Dfile.encoding=utf-8 zkt-project-alarm.jar
+java -jar $JAVA_OPTS ibms-project-alarm.jar

+ 1 - 1
pom.xml

@@ -167,7 +167,7 @@
     </dependencies>
 
     <build>
-        <finalName>${project.artifactId}</finalName>
+        <finalName>ibms-project-alarm</finalName>
         <plugins>
             <plugin>
                 <groupId>org.apache.maven.plugins</groupId>

+ 8 - 9
src/main/java/com/persagy/netty/client/CenterClientHandler.java

@@ -48,20 +48,19 @@ public class CenterClientHandler extends SimpleChannelInboundHandler<NettyMessag
     @Override
     public void channelActive(ChannelHandlerContext ctx) throws Exception {
         log.info("Connected to: {}", ctx.channel().remoteAddress());
-
-        //建立连接
+        // 建立连接
         nettyClient.sendMessage(new NettyMessage(200));
-
-        //启动的时候发送消息,获取全部报警定义
+        
+        //内存中缓冲的未发送成功的数据发送出去
+        iniAlarmResult(ctx);
+        
+		// 获取全部报警定义
         NettyMessage nettyMessage = new NettyMessage(4);
         JSONObject content = new JSONObject();
         content.put("groupCode", CommonConst.groupCode);
         content.put("projectId", CommonConst.projectId);
         nettyMessage.setContent(Arrays.asList(content));
         nettyClient.sendMessage(nettyMessage);
-
-        //内存中缓冲的未发送成功的数据发送出去
-        iniAlarmResult(ctx);
     }
 
     private void iniAlarmResult(ChannelHandlerContext ctx) {
@@ -84,14 +83,14 @@ public class CenterClientHandler extends SimpleChannelInboundHandler<NettyMessag
         try {
             TimeInterval timer = DateUtil.timer();
             handlerMsg(ctx, msg);
-            log.info("处理消息时间[{}]", timer.interval());
+            log.info("处理消息时间[{} ms]", timer.interval());
         } catch (Exception e) {
             log.error("channelRead", e);
         }
     }
 
     private void handlerMsg(ChannelHandlerContext channelHandlerContext, NettyMessage msg) throws Exception {
-        if (msg.getOpCode() == 7) {
+    	if (msg.getOpCode() == 7) {
             log.info("--报警定义新增或更新--{}",msg);
             NettyMessage<AlarmDefine> AlarmDefineMessage = JSONObject.parseObject(msg.toString(), new TypeReference<NettyMessage<AlarmDefine>>() {
             });

+ 2 - 2
src/main/resources/application-XGPj5001120003.yml

@@ -12,9 +12,9 @@ remote:
     # 推送消息时,是否会开启压缩,true-压缩 false-不压缩
     compress: false
     # 需要更改
-    host: 192.168.0.27
+    host: 192.168.100.102
     # 需要更改
-    port: 8836
+    port: 30050
 
   # IOT程序
   iot:

+ 1 - 1
src/main/resources/application.yml

@@ -4,7 +4,7 @@ server:
 spring:
   # 应用名称
   application:
-    name: zkt-project-alarm
+    name: ibms-project-alarm
   profiles:
     active: WDPj4403070003 #39Pj5001120003 #Pj4403070003 #Pj3201110003
   datasource: