修复打包bug
This commit is contained in:
@@ -1,9 +1,7 @@
|
|||||||
rabitMQTT
|
rabitMQTT
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
|
|
||||||
docker run -d -it -p 5672:5672 -p 15672:15672 --name rabbitmq rabbitmq:management
|
docker run -d -it -p 5672:5672 -p 15672:15672 --name rabbitmq rabbitmq:management
|
||||||
|
|
||||||
```
|
```
|
||||||
在web管理后台新建Exchanges :
|
在web管理后台新建Exchanges :
|
||||||
`messageService2Pipeline`
|
`messageService2Pipeline`
|
||||||
@@ -13,3 +11,14 @@ docker run -d -it -p 5672:5672 -p 15672:15672 --name rabbitmq rabbitmq:managem
|
|||||||
zookeeper搭建教程
|
zookeeper搭建教程
|
||||||
|
|
||||||
https://blog.csdn.net/weixin_43559374/article/details/131588024
|
https://blog.csdn.net/weixin_43559374/article/details/131588024
|
||||||
|
|
||||||
|
|
||||||
|
docker run -e TZ="Asia/Shanghai" -d --restart=always -p 28989:8989 --privileged=true -v /home/workplace/im/app-service-1.0-SNAPSHOT:/usr/local/src/app.jar --name im-app-service java:8 nohup java -jar /usr/local/src/app.jar --myRedis.seconds=20 &
|
||||||
|
|
||||||
|
docker run -e TZ="Asia/Shanghai" -d --restart=always -p 29000:29000 -p 19000:19000 --privileged=true -v /home/workplace/im/im-tcp-1.0.0-SNAPSHOT.jar:/usr/local/src/app.jar -v /home/workplace/im/config.yml:/usr/local/src/config.yml --name im-tcp-1 anapsix/alpine-java:8_server-jre_unlimited nohup java -jar /usr/local/src/app.jar /usr/local/src/config.yml 2>&1 &
|
||||||
|
|
||||||
|
docker run -e TZ="Asia/Shanghai" -d --restart=always -p 29002:29002 -p 19002:19002 --privileged=true -v /home/workplace/im/im-tcp-1.0.0-SNAPSHOT.jar:/usr/local/src/app.jar -v /home/workplace/im/config2.yml:/usr/local/src/config.yml --name im-tcp-2 anapsix/alpine-java:8_server-jre_unlimited nohup java -jar /usr/local/src/app.jar /usr/local/src/config.yml 2>&1 &
|
||||||
|
|
||||||
|
docker run -d -e TZ="Asia/Shanghai" --restart=always --privileged=true -p 28000:28000 -v /home/workplace/im/im-service-1.0.0-SNAPSHOT.jar:/usr/local/src/app.jar --name im-service anapsix/alpine-java:8_server-jre_unlimited nohup java -jar /usr/local/src/app.jar --myRedis.seconds=20 2>&1 &
|
||||||
|
|
||||||
|
docker run -d -e TZ="Asia/Shanghai" --restart=always --privileged=true -v /home/workplace/im/im-message-store-1.0.0-SNAPSHOT.jar:/usr/local/src/app.jar --name im-message-store anapsix/alpine-java:8_server-jre_unlimited nohup java -jar /usr/local/src/app.jar --myRedis.seconds=20 2>&1 &
|
||||||
|
|||||||
@@ -39,14 +39,6 @@
|
|||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<build>
|
|
||||||
<plugins>
|
|
||||||
<plugin>
|
|
||||||
<groupId>org.springframework.boot</groupId>
|
|
||||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
|
||||||
</plugin>
|
|
||||||
</plugins>
|
|
||||||
</build>
|
|
||||||
|
|
||||||
|
|
||||||
</project>
|
</project>
|
||||||
|
|||||||
@@ -38,12 +38,6 @@
|
|||||||
<artifactId>zkclient</artifactId>
|
<artifactId>zkclient</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.lld</groupId>
|
|
||||||
<artifactId>common</artifactId>
|
|
||||||
<version>1.0.0-SNAPSHOT</version>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<!-- netty -->
|
<!-- netty -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>io.netty</groupId>
|
<groupId>io.netty</groupId>
|
||||||
@@ -82,22 +76,21 @@
|
|||||||
<groupId>com.lld</groupId>
|
<groupId>com.lld</groupId>
|
||||||
<artifactId>im-codec</artifactId>
|
<artifactId>im-codec</artifactId>
|
||||||
<version>1.0.0-SNAPSHOT</version>
|
<version>1.0.0-SNAPSHOT</version>
|
||||||
<scope>compile</scope>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-web</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
<plugins>
|
<plugins>
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<artifactId>maven-compiler-plugin</artifactId>
|
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||||
<configuration>
|
|
||||||
<source>8</source>
|
|
||||||
<target>8</target>
|
|
||||||
</configuration>
|
|
||||||
</plugin>
|
</plugin>
|
||||||
</plugins>
|
</plugins>
|
||||||
</build>
|
</build>
|
||||||
|
|
||||||
</project>
|
</project>
|
||||||
|
|||||||
@@ -9,6 +9,8 @@ import com.lld.im.tcp.server.LimServer;
|
|||||||
import com.lld.im.tcp.server.LimWebSocketServer;
|
import com.lld.im.tcp.server.LimWebSocketServer;
|
||||||
import com.lld.im.tcp.utils.MqFactory;
|
import com.lld.im.tcp.utils.MqFactory;
|
||||||
import org.I0Itec.zkclient.ZkClient;
|
import org.I0Itec.zkclient.ZkClient;
|
||||||
|
import org.springframework.boot.SpringApplication;
|
||||||
|
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||||
import org.yaml.snakeyaml.Yaml;
|
import org.yaml.snakeyaml.Yaml;
|
||||||
|
|
||||||
import java.io.FileInputStream;
|
import java.io.FileInputStream;
|
||||||
@@ -16,45 +18,10 @@ import java.io.InputStream;
|
|||||||
import java.net.InetAddress;
|
import java.net.InetAddress;
|
||||||
import java.net.UnknownHostException;
|
import java.net.UnknownHostException;
|
||||||
|
|
||||||
|
@SpringBootApplication
|
||||||
public class Starter {
|
public class Starter {
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
if(args.length > 0){
|
SpringApplication.run(Starter.class, args);
|
||||||
start(args[0]);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void start(String path){
|
|
||||||
try {
|
|
||||||
Yaml yaml = new Yaml();
|
|
||||||
InputStream inputStream = new FileInputStream(path);
|
|
||||||
BootstrapConfig bootstrapConfig = yaml.loadAs(inputStream, BootstrapConfig.class);
|
|
||||||
|
|
||||||
new LimServer(bootstrapConfig.getLim()).start();
|
|
||||||
new LimWebSocketServer(bootstrapConfig.getLim());
|
|
||||||
|
|
||||||
|
|
||||||
RedisManager.init(bootstrapConfig);
|
|
||||||
MqFactory.init(bootstrapConfig.getLim().getRabbitmq());
|
|
||||||
MessageReciver.init(bootstrapConfig.getLim().getBrokerId()+"");
|
|
||||||
|
|
||||||
registerZK(bootstrapConfig);
|
|
||||||
|
|
||||||
}catch (Exception e){
|
|
||||||
e.printStackTrace();
|
|
||||||
System.exit(500);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public static void registerZK(BootstrapConfig config) throws UnknownHostException {
|
|
||||||
String hostAddress = InetAddress.getLocalHost().getHostAddress();
|
|
||||||
ZkClient zkClient = new ZkClient(config.getLim().getZkConfig().getZkAddr(),
|
|
||||||
config.getLim().getZkConfig().getZkConnectTimeOut());
|
|
||||||
ZKit zKit = new ZKit(zkClient);
|
|
||||||
RegistryZK registryZK = new RegistryZK(zKit, hostAddress, config.getLim());
|
|
||||||
Thread thread = new Thread(registryZK);
|
|
||||||
thread.start();
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,74 @@
|
|||||||
|
package com.lld.im.tcp;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSONArray;
|
||||||
|
import com.lld.im.codec.config.BootstrapConfig;
|
||||||
|
import com.lld.im.tcp.reciver.MessageReciver;
|
||||||
|
import com.lld.im.tcp.redis.RedisManager;
|
||||||
|
import com.lld.im.tcp.register.RegistryZK;
|
||||||
|
import com.lld.im.tcp.register.ZKit;
|
||||||
|
import com.lld.im.tcp.server.LimServer;
|
||||||
|
import com.lld.im.tcp.server.LimWebSocketServer;
|
||||||
|
import com.lld.im.tcp.utils.MqFactory;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.I0Itec.zkclient.ZkClient;
|
||||||
|
import org.springframework.boot.ApplicationArguments;
|
||||||
|
import org.springframework.boot.ApplicationRunner;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
import org.yaml.snakeyaml.Yaml;
|
||||||
|
|
||||||
|
import java.io.FileInputStream;
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.net.InetAddress;
|
||||||
|
import java.net.UnknownHostException;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Slf4j
|
||||||
|
@Component
|
||||||
|
public class StarterServer implements ApplicationRunner {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void run(ApplicationArguments args) throws Exception {
|
||||||
|
log.info("--------------------------SpringBoot启动执行方法-----------------------------");
|
||||||
|
List<String> nonOptionArgs = args.getNonOptionArgs();
|
||||||
|
log.info("-->> start: {}", JSONArray.toJSONString(nonOptionArgs));
|
||||||
|
if(nonOptionArgs.size() > 0){
|
||||||
|
start(nonOptionArgs.get(0));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void start(String path){
|
||||||
|
try {
|
||||||
|
Yaml yaml = new Yaml();
|
||||||
|
InputStream inputStream = new FileInputStream(path);
|
||||||
|
BootstrapConfig bootstrapConfig = yaml.loadAs(inputStream, BootstrapConfig.class);
|
||||||
|
|
||||||
|
new LimServer(bootstrapConfig.getLim()).start();
|
||||||
|
new LimWebSocketServer(bootstrapConfig.getLim());
|
||||||
|
|
||||||
|
|
||||||
|
RedisManager.init(bootstrapConfig);
|
||||||
|
MqFactory.init(bootstrapConfig.getLim().getRabbitmq());
|
||||||
|
MessageReciver.init(bootstrapConfig.getLim().getBrokerId()+"");
|
||||||
|
|
||||||
|
registerZK(bootstrapConfig);
|
||||||
|
|
||||||
|
}catch (Exception e){
|
||||||
|
e.printStackTrace();
|
||||||
|
System.exit(500);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
private void registerZK(BootstrapConfig config) throws UnknownHostException {
|
||||||
|
String hostAddress = InetAddress.getLocalHost().getHostAddress();
|
||||||
|
ZkClient zkClient = new ZkClient(config.getLim().getZkConfig().getZkAddr(),
|
||||||
|
config.getLim().getZkConfig().getZkConnectTimeOut());
|
||||||
|
ZKit zKit = new ZKit(zkClient);
|
||||||
|
RegistryZK registryZK = new RegistryZK(zKit, hostAddress, config.getLim());
|
||||||
|
Thread thread = new Thread(registryZK);
|
||||||
|
thread.start();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,27 @@
|
|||||||
|
package com.lld.im.tcp.controller;
|
||||||
|
|
||||||
|
import com.lld.im.common.ResponseVO;
|
||||||
|
import com.lld.im.common.model.SyncReq;
|
||||||
|
import com.lld.im.common.model.message.CheckSendMessageReq;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description:
|
||||||
|
* @author: lld
|
||||||
|
* @version: 1.0
|
||||||
|
*/
|
||||||
|
@RestController
|
||||||
|
public class MessageController {
|
||||||
|
|
||||||
|
|
||||||
|
@RequestMapping("/send")
|
||||||
|
public String send(@RequestBody @Validated Integer appId) {
|
||||||
|
return "OK";
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
3
hs-im-server/im-tcp/src/main/resources/application.yml
Normal file
3
hs-im-server/im-tcp/src/main/resources/application.yml
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
spring:
|
||||||
|
profiles:
|
||||||
|
active: dev
|
||||||
88
hs-im-server/im-tcp/src/main/resources/logback-spring.xml
Normal file
88
hs-im-server/im-tcp/src/main/resources/logback-spring.xml
Normal file
@@ -0,0 +1,88 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8" ?>
|
||||||
|
|
||||||
|
<!-- 日志级别从低到高分为TRACE < DEBUG < INFO < WARN < ERROR < FATAL,如果设置为WARN,则低于WARN的信息都不会输出 -->
|
||||||
|
<!-- scan:当此属性设置为true时,配置文件如果发生改变,将会被重新加载,默认值为true -->
|
||||||
|
<!-- scanPeriod:设置监测配置文件是否有修改的时间间隔,如果没有给出时间单位,默认单位是毫秒。当scan为true时,此属性生效。默认的时间间隔为1分钟。 -->
|
||||||
|
<!-- debug:当此属性设置为true时,将打印出logback内部日志信息,实时查看logback运行状态。默认值为false。 -->
|
||||||
|
|
||||||
|
<configuration scan="true" scanPeriod="10 seconds" >
|
||||||
|
|
||||||
|
<include resource="org/springframework/boot/logging/logback/defualts.xml"/>
|
||||||
|
|
||||||
|
<springProperty scope="context" name="springAppName" source="spring.application.name"/>
|
||||||
|
<springProperty scope="context" name="springAppEnv" source="spring.profiles.active"/>
|
||||||
|
<!-- <springProperty scope="context" name="logFile" source="logging.file"/> -->
|
||||||
|
|
||||||
|
<property name="logFile" value="logs/mylog.log"/>
|
||||||
|
<!--日志在工程中的输出位置-->
|
||||||
|
<property name="LOG_FILE" value="${logFile}"/>
|
||||||
|
<!-- 彩色日志依赖的渲染类 -->
|
||||||
|
<conversionRule conversionWord="clr" converterClass="org.springframework.boot.logging.logback.ColorConverter"/>
|
||||||
|
<conversionRule conversionWord="wex"
|
||||||
|
converterClass="org.springframework.boot.logging.logback.WhitespaceThrowableProxyConverter"/>
|
||||||
|
<conversionRule conversionWord="wEx"
|
||||||
|
converterClass="org.springframework.boot.logging.logback.ExtendedWhitespaceThrowableProxyConverter"/>
|
||||||
|
<!--控制台的日志输出样式-->
|
||||||
|
<property name="CONSOLE_LOG_PATTERN"
|
||||||
|
value="${CONSOLE_LOG_PATTERN:-%clr(%d{yyyy-MM-dd HH:mm:ss.SSS}){faint} %clr(${LOG_LEVEL_PATTERN:-%5p}) %clr(${PID:- }){magenta} %clr(---){faint} %clr([%15.15t]){faint} %clr(%-40.40logger{39}){cyan} %clr(:){faint} %m%n${LOG_EXCEPTION_CONVERSION_WORD:-%wEx}}"/>
|
||||||
|
|
||||||
|
|
||||||
|
<!--控制台 Appender-->
|
||||||
|
<appender name="console" class="ch.qos.logback.core.ConsoleAppender">
|
||||||
|
<filter class="ch.qos.logback.classic.filter.ThresholdFilter">
|
||||||
|
<level>DEBUG</level>
|
||||||
|
</filter>
|
||||||
|
<encoder>
|
||||||
|
<pattern>${CONSOLE_LOG_PATTERN}</pattern>
|
||||||
|
<charset>utf8</charset>
|
||||||
|
</encoder>
|
||||||
|
</appender>
|
||||||
|
|
||||||
|
|
||||||
|
<!--隐藏服务发现后输出的日志-->
|
||||||
|
<logger name="com.netflix.discovery.shared.resolver.aws.ConfigClusterResolver" level="WARN"/>
|
||||||
|
<logger name="org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping" level="WARN"/>
|
||||||
|
|
||||||
|
|
||||||
|
<springProfile name="test,dev">
|
||||||
|
<!--文件-->
|
||||||
|
<appender name="fileAppender" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
||||||
|
<Prudent>true</Prudent>
|
||||||
|
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
|
||||||
|
<FileNamePattern>
|
||||||
|
${logFile}.%d{yyyy-MM-dd}.log
|
||||||
|
</FileNamePattern>
|
||||||
|
</rollingPolicy>
|
||||||
|
<layout class="ch.qos.logback.classic.PatternLayout">
|
||||||
|
<Pattern>
|
||||||
|
%d{yyyy-MM-dd HH:mm:ss} -%msg%n
|
||||||
|
</Pattern>
|
||||||
|
</layout>
|
||||||
|
</appender>
|
||||||
|
<root level="INFO">
|
||||||
|
<appender-ref ref="console"/>
|
||||||
|
<appender-ref ref="fileAppender"/>
|
||||||
|
</root>
|
||||||
|
</springProfile>
|
||||||
|
<springProfile name="prod">
|
||||||
|
<!--文件-->
|
||||||
|
<appender name="fileAppender" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
||||||
|
<Prudent>true</Prudent>
|
||||||
|
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
|
||||||
|
<FileNamePattern>
|
||||||
|
${logFile}.%d{yyyy-MM-dd}.log
|
||||||
|
</FileNamePattern>
|
||||||
|
</rollingPolicy>
|
||||||
|
<layout class="ch.qos.logback.classic.PatternLayout">
|
||||||
|
<Pattern>
|
||||||
|
%d{yyyy-MM-dd HH:mm:ss} -%msg%n
|
||||||
|
</Pattern>
|
||||||
|
</layout>
|
||||||
|
</appender>
|
||||||
|
<root level="WARN">
|
||||||
|
<appender-ref ref="console"/>
|
||||||
|
<appender-ref ref="fileAppender"/>
|
||||||
|
</root>
|
||||||
|
</springProfile>
|
||||||
|
|
||||||
|
</configuration>
|
||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user