Forráskód Böngészése

整理配置文件

xsx 1 éve
szülő
commit
e2cd53d515

+ 27 - 0
im-platform/src/main/resources/application-dev.yml

@@ -0,0 +1,27 @@
+spring:
+  datasource:
+    driver-class-name: com.mysql.cj.jdbc.Driver
+    url: jdbc:mysql://localhost:3306/box-im?useSSL=false&useUnicode=true&characterEncoding=utf-8&allowPublicKeyRetrieval=true
+    username: root
+    password: root
+  data:
+    redis:
+      host: localhost
+      port: 6379
+
+minio:
+  endpoint: http://127.0.0.1:9001 #内网地址
+  public: http://127.0.0.1:9001  #外网访问地址
+  accessKey: admin
+  secretKey: admin123456
+  bucketName: box-im
+  imagePath: image
+  filePath: file
+  videoPath: video
+
+webrtc:
+  max-channel: 9 # 多人通话最大通道数量,最大不能超过16,建议值:4,9,16
+  iceServers:
+    - urls: stun:stun.l.google.com:19302
+
+

+ 26 - 0
im-platform/src/main/resources/application-prod.yml

@@ -0,0 +1,26 @@
+spring:
+  datasource:
+    driver-class-name: com.mysql.cj.jdbc.Driver
+    url: jdbc:mysql://localhost:3306/box-im?useSSL=false&useUnicode=true&characterEncoding=utf-8&allowPublicKeyRetrieval=true
+    username: root
+    password: root
+  data:
+    redis:
+      host: localhost
+      port: 6379
+
+minio:
+  endpoint: http://127.0.0.1:9001 #内网地址
+  public: http://127.0.0.1:9001  #外网访问地址
+  accessKey: admin
+  secretKey: admin123456
+  bucketName: box-im
+  imagePath: image
+  filePath: file
+  videoPath: video
+
+webrtc:
+  max-channel: 9 # 多人通话最大通道数量,最大不能超过16,建议值:4,9,16
+  iceServers:
+    - urls: stun:stun.l.google.com:19302
+

+ 25 - 0
im-platform/src/main/resources/application-test.yml

@@ -0,0 +1,25 @@
+spring:
+  datasource:
+    driver-class-name: com.mysql.cj.jdbc.Driver
+    url: jdbc:mysql://localhost:3306/box-im?useSSL=false&useUnicode=true&characterEncoding=utf-8&allowPublicKeyRetrieval=true
+    username: root
+    password: root
+  data:
+    redis:
+      host: localhost
+      port: 6379
+
+minio:
+  endpoint: http://127.0.0.1:9001 #内网地址
+  public: http://127.0.0.1:9001  #外网访问地址
+  accessKey: admin
+  secretKey: admin123456
+  bucketName: box-im
+  imagePath: image
+  filePath: file
+  videoPath: video
+
+webrtc:
+  max-channel: 9 # 多人通话最大通道数量,最大不能超过16,建议值:4,9,16
+  iceServers:
+    - urls: stun:stun.l.google.com:19302

+ 4 - 27
im-platform/src/main/resources/application.yml

@@ -1,23 +1,13 @@
 server:
   port: 8888
 spring:
+  profiles:
+    active: dev # 环境 dev|test|prod
   application:
     name: im-platform
   mvc:
     pathmatch:
       matching-strategy: ant_path_matcher
-  datasource:
-    driver-class-name: com.mysql.cj.jdbc.Driver
-    url: jdbc:mysql://localhost:3306/box-im?useSSL=false&useUnicode=true&characterEncoding=utf-8&allowPublicKeyRetrieval=true
-    username: root
-    password: root
-
-  data:
-    redis:
-      host: localhost
-      port: 6379
-      database: 2
-
   servlet:
     multipart:
       max-file-size: 50MB
@@ -31,21 +21,6 @@ mybatis-plus:
     map-underscore-to-camel-case: true  #开启自动驼峰命名规则
     log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
 
-minio:
-  endpoint: http://127.0.0.1:9001 #内网地址
-  public: http://192.168.2.67:9001  #外网访问地址
-  accessKey: admin
-  secretKey: 12345678
-  bucketName: box-im
-  imagePath: image
-  filePath: file
-  videoPath: video
-
-webrtc:
-  max-channel: 9 # 多人通话最大通道数量,最大不能超过16,建议值:4,9,16
-  iceServers:
-    - urls: stun:stun.l.google.com:19302
-
 jwt:
   accessToken:
     expireIn: 1800 #半个小时
@@ -54,3 +29,5 @@ jwt:
     expireIn: 604800 #7天
     secret: IKDiqVmn0VFU
 
+
+

+ 48 - 0
im-platform/src/main/resources/logback.xml

@@ -0,0 +1,48 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<configuration>
+    <include resource="org/springframework/boot/logging/logback/defaults.xml" />
+    <property name="LOG_PATH" value="log"/>
+    <property name="LOG_NAME" value="im-platform.log"/>
+    <appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
+        <filter class="ch.qos.logback.classic.filter.ThresholdFilter">
+            <level>info</level>
+        </filter>
+        <encoder>
+            <pattern>%date [%level] [%thread] [%file : %line] %msg%n</pattern>
+            <charset>UTF-8</charset>
+        </encoder>
+    </appender>
+    <appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
+        <File>${LOG_PATH}/${LOG_NAME}</File>
+        <encoder>
+            <pattern>%date [%level] [%thread] [%file : %line] %msg%n</pattern>
+            <charset>UTF-8</charset>
+        </encoder>
+        <rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
+            <fileNamePattern>${LOG_PATH}/info-%d{yyyy-MM-dd}.%i.log</fileNamePattern>
+            <maxFileSize>100MB</maxFileSize>
+            <maxHistory>60</maxHistory>
+            <totalSizeCap>20GB</totalSizeCap>
+        </rollingPolicy>
+    </appender>
+    <!-- 开发环境下的日志配置 -->
+    <springProfile name="dev">
+        <root level="INFO">
+            <appender-ref ref="CONSOLE"/>
+        </root>
+    </springProfile>
+    <!-- 测试环境下的日志配置 -->
+    <springProfile name="test">
+        <root level="INFO">
+            <appender-ref ref="CONSOLE"/>
+            <appender-ref ref="FILE"/>
+        </root>
+    </springProfile>
+    <!-- 生产环境下的日志配置 -->
+    <springProfile name="prod">
+        <root level="INFO">
+            <appender-ref ref="CONSOLE"/>
+            <appender-ref ref="FILE"/>
+        </root>
+    </springProfile>
+</configuration>

+ 5 - 0
im-server/src/main/resources/application-dev.yml

@@ -0,0 +1,5 @@
+spring:
+  redis:
+    host: 127.0.0.1
+    port: 6379
+

+ 4 - 0
im-server/src/main/resources/application-prod.yml

@@ -0,0 +1,4 @@
+spring:
+  redis:
+    host: 127.0.0.1
+    port: 6379

+ 4 - 0
im-server/src/main/resources/application-test.yml

@@ -0,0 +1,4 @@
+spring:
+  redis:
+    host: 127.0.0.1
+    port: 6379

+ 5 - 6
im-server/src/main/resources/application.yml

@@ -1,9 +1,8 @@
 spring:
-  data:
-    redis:
-      host: localhost
-      port: 6379
-      database: 2
+  profiles:
+    active: dev
+  application:
+    name: im-server
 
 websocket:
   enable: true
@@ -15,4 +14,4 @@ tcpsocket:
 
 jwt:
   accessToken:
-    secret: MIIBIjANBgkq  # 跟im-platfrom的secret必须一致
+    secret: MIIBIjANBgkq  # 跟im-platfrom的secret必须一致

+ 48 - 0
im-server/src/main/resources/logback.xml

@@ -0,0 +1,48 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<configuration>
+    <include resource="org/springframework/boot/logging/logback/defaults.xml" />
+    <property name="LOG_PATH" value="log"/>
+    <property name="LOG_NAME" value="im-server.log"/>
+    <appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
+        <filter class="ch.qos.logback.classic.filter.ThresholdFilter">
+            <level>info</level>
+        </filter>
+        <encoder>
+            <pattern>%date [%level] [%thread] [%file : %line] %msg%n</pattern>
+            <charset>UTF-8</charset>
+        </encoder>
+    </appender>
+    <appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
+        <File>${LOG_PATH}/${LOG_NAME}</File>
+        <encoder>
+            <pattern>%date [%level] [%thread] [%file : %line] %msg%n</pattern>
+            <charset>UTF-8</charset>
+        </encoder>
+        <rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
+            <fileNamePattern>${LOG_PATH}/info-%d{yyyy-MM-dd}.%i.log</fileNamePattern>
+            <maxFileSize>100MB</maxFileSize>
+            <maxHistory>60</maxHistory>
+            <totalSizeCap>20GB</totalSizeCap>
+        </rollingPolicy>
+    </appender>
+    <!-- 开发环境下的日志配置 -->
+    <springProfile name="dev">
+        <root level="INFO">
+            <appender-ref ref="CONSOLE"/>
+        </root>
+    </springProfile>
+    <!-- 测试环境下的日志配置 -->
+    <springProfile name="test">
+        <root level="INFO">
+            <appender-ref ref="CONSOLE"/>
+            <appender-ref ref="FILE"/>
+        </root>
+    </springProfile>
+    <!-- 生产环境下的日志配置 -->
+    <springProfile name="prod">
+        <root level="INFO">
+            <appender-ref ref="CONSOLE"/>
+            <appender-ref ref="FILE"/>
+        </root>
+    </springProfile>
+</configuration>