瀏覽代碼

打包配置、批量启动shell脚本

wangqi49 3 周之前
父節點
當前提交
08bff9a71f

+ 0 - 9
pom.xml

@@ -110,15 +110,6 @@
         </dependencies>
     </dependencyManagement>
 
-    <build>
-        <plugins>
-            <plugin>
-                <groupId>org.springframework.boot</groupId>
-                <artifactId>spring-boot-maven-plugin</artifactId>
-            </plugin>
-        </plugins>
-    </build>
-
     <profiles>
         <profile>
             <id>dev</id>

+ 0 - 0
resources/database-sql/webchat-event.sql


+ 0 - 0
resources/database-sql/webchat-core.sql → resources/database-sql/webchat.sql


+ 109 - 0
start.sh

@@ -0,0 +1,109 @@
+#!/bin/bash
+
+# 定义默认启动模式及路径
+SERVER="all"
+WEB_CHAT_START_PAGE_JARS="./server"
+KILL_TIMEOUT=5  # 等待进程退出的最长时间(秒)
+
+# 参数处理(支持带.jar后缀和不带的情况)
+if [ $# -gt 0 ]; then
+  SERVER="${1%.*}" # 去除可能的.jar后缀
+fi
+
+echo "Starting server: $SERVER"
+
+# 打包阶段
+echo "=== Webchat packaging begins ==="
+mvn clean package -DskipTests=true
+echo "=== Webchat packaging completed ==="
+
+# 清理并创建jars目录
+rm -rf "$WEB_CHAT_START_PAGE_JARS"
+mkdir -p "$WEB_CHAT_START_PAGE_JARS"
+echo "Old jars removed"
+
+# 复制所有jar到目标目录
+find . -path "*/target/*.jar" -exec cp {} "$WEB_CHAT_START_PAGE_JARS" \;
+
+cd "$WEB_CHAT_START_PAGE_JARS" || exit 1
+
+# 定义进程终止函数
+kill_old_process() {
+  local jar_name=$1
+  local pid_list=$(pgrep -f "java.*$jar_name")
+
+  if [ -n "$pid_list" ]; then
+    echo "Found existing process(es) for $jar_name: $pid_list"
+
+    # 优雅终止
+    kill $pid_list
+    echo "Sent SIGTERM to process(es), waiting for termination..."
+
+    # 等待进程退出
+    local timeout=0
+    while kill -0 $pid_list 2>/dev/null && [ $timeout -lt $KILL_TIMEOUT ]; do
+      sleep 1
+      ((timeout++))
+    done
+
+    # 强制终止未退出的进程
+    if kill -0 $pid_list 2>/dev/null; then
+      echo "Force killing process(es)..."
+      kill -9 $pid_list
+    fi
+
+    # 二次确认
+    if pgrep -f "java.*$jar_name" >/dev/null; then
+      echo "Error: Failed to kill process for $jar_name!" >&2
+      return 1
+    fi
+  fi
+  return 0
+}
+
+# 启动逻辑
+if [ "$SERVER" == "all" ]; then
+  echo "Starting ALL services..."
+  for jar in *.jar; do
+    service_name="${jar%.*}"
+
+    # 终止旧进程
+    if ! kill_old_process "$jar"; then
+      exit 1
+    fi
+
+    # 启动新进程
+    echo "Starting $service_name..."
+    nohup java -jar "$jar" > "${service_name}.log" 2>&1 &
+  done
+  echo "All services restarted in background."
+else
+  target_jar="${SERVER}.jar"
+  if [ -f "$target_jar" ]; then
+    # 终止旧进程
+    if ! kill_old_process "$target_jar"; then
+      exit 1
+    fi
+
+    # 启动新进程
+    echo "Starting $target_jar..."
+    nohup java -jar "$target_jar" > "${SERVER}.log" 2>&1 &
+    echo "Service restarted. Tracking logs:"
+    tail -100f "${SERVER}.log"
+  else
+    echo "Error: Jar file $target_jar not found!"
+    echo "Available jars:"
+    ls -1 *.jar | sed 's/.jar$//'
+    exit 1
+  fi
+fi
+
+# 端口冲突检查(备用方案)
+check_port_conflict() {
+  local port=$1
+  if lsof -i :$port &>/dev/null; then
+    echo "Port $port is still in use after process restart!" >&2
+    return 1
+  fi
+  return 0
+}

+ 2 - 0
webchat-act/pom.xml

@@ -40,7 +40,9 @@
             <version>1.0-SNAPSHOT</version>
         </dependency>
     </dependencies>
+
     <build>
+        <finalName>webchat-act</finalName>
         <plugins>
             <plugin>
                 <groupId>org.springframework.boot</groupId>

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

@@ -1 +1 @@
-server:
  port: 8018
+server:
  port: 8025

+ 1 - 0
webchat-admin/pom.xml

@@ -40,6 +40,7 @@
     </dependencies>
 
     <build>
+        <finalName>webchat-admin</finalName>
         <plugins>
             <plugin>
                 <groupId>org.springframework.boot</groupId>

+ 1 - 0
webchat-aigc/pom.xml

@@ -41,6 +41,7 @@
     </dependencies>
 
     <build>
+        <finalName>webchat-aigc</finalName>
         <plugins>
             <plugin>
                 <groupId>org.springframework.boot</groupId>

+ 1 - 0
webchat-client-chat/pom.xml

@@ -39,6 +39,7 @@
     </dependencies>
 
     <build>
+        <finalName>webchat-client-chat</finalName>
         <plugins>
             <plugin>
                 <groupId>org.springframework.boot</groupId>

+ 4 - 3
webchat-common/src/main/java/com/webchat/common/config/configuration/RedissonConfig.java

@@ -10,10 +10,10 @@ import org.springframework.context.annotation.Configuration;
 @Configuration
 public class RedissonConfig {
 
-    @Value("${spring.redis.host:localhost}")
+    @Value("${spring.data.redis.host:localhost}")
     private String host;
 
-    @Value("${spring.redis.port:6379}")
+    @Value("${spring.data.redis.port:6379}")
     private String port;
 
     /**
@@ -29,7 +29,8 @@ public class RedissonConfig {
         // config.useClusterServers().addNodeAddress("127.0.0.1:7004", "127.0.0.1:7001");
         // 根据 Config 创建出 RedissonClient 示例
         config.useSingleServer()
-                .setAddress(String.format("redis://%s:%s", host, port));
+                .setAddress(String.format("redis://%s:%s", host, port))
+                .setDatabase(0);
         return Redisson.create(config);
     }
 }

+ 1 - 1
webchat-common/src/main/java/com/webchat/common/enums/RoleCodeEnum.java

@@ -5,7 +5,7 @@ import lombok.Getter;
 @Getter
 public enum RoleCodeEnum {
 
-    FILE_ACCOUNT(0, "文件传输助手"),
+    AIBOT(0, "文件传输助手"),
 
     USER(1, "普通用户"),
 

+ 1 - 0
webchat-connect/pom.xml

@@ -43,6 +43,7 @@
     </dependencies>
 
     <build>
+        <finalName>webchat-connect</finalName>
         <plugins>
             <plugin>
                 <groupId>org.springframework.boot</groupId>

+ 1 - 0
webchat-connect/src/main/java/com/webchat/connect/messagequeue/consumer/service/GroupVideoCallConsumeService.java

@@ -87,6 +87,7 @@ public class GroupVideoCallConsumeService {
                 } catch (IOException e) {
                     // 这里不能跑出异常,否则会中断整个推送任务
                     // TODO 处理策略:重拾一次/预警通知
+
                 }
             }
 

+ 2 - 1
webchat-connect/src/main/java/com/webchat/connect/websocket/handler/ChatWebSocketEndPointServletHandler.java

@@ -86,7 +86,8 @@ public class ChatWebSocketEndPointServletHandler extends TextWebSocketHandler {
         if (accountInfo == null) {
             return;
         }
-        if (RoleCodeEnum.ROBOT.getCode().equals(accountInfo.getRoleCode())) {
+        if (RoleCodeEnum.ROBOT.getCode().equals(accountInfo.getRoleCode()) ||
+                RoleCodeEnum.AIBOT.getCode().equals(accountInfo.getRoleCode())) {
             /**
              * 机器人AGENT对话,走AGENT工作流处理
              */

+ 1 - 0
webchat-gateway/pom.xml

@@ -66,6 +66,7 @@
 
     </dependencies>
     <build>
+        <finalName>webchat-gateway</finalName>
         <plugins>
             <plugin>
                 <groupId>org.springframework.boot</groupId>

File diff suppressed because it is too large
+ 0 - 0
webchat-gateway/src/main/resources/application.yml


+ 1 - 0
webchat-pay/pom.xml

@@ -42,6 +42,7 @@
     </dependencies>
 
     <build>
+        <finalName>webchat-pay</finalName>
         <plugins>
             <plugin>
                 <groupId>org.springframework.boot</groupId>

+ 1 - 1
webchat-pay/src/main/java/com/webchat/pay/service/PaymentAppService.java

@@ -260,7 +260,7 @@ public class PaymentAppService {
             appEntity.setAdmin(createAppRequest.getUserId());
             appEntity.setCreateBy(createAppRequest.getUserId());
             // 后面改成默认新建状态
-            appEntity.setStatus(CommonStatusEnum.PUBLISHED.getStatusCode());
+            appEntity.setStatus(CommonStatusEnum.NEW.getStatusCode());
         }
         appEntity.setLogo(createAppRequest.getLogo());
         appEntity.setName(createAppRequest.getName());

+ 1 - 0
webchat-pgc/pom.xml

@@ -41,6 +41,7 @@
         </dependency>
     </dependencies>
     <build>
+        <finalName>webchat-pgc</finalName>
         <plugins>
             <plugin>
                 <groupId>org.springframework.boot</groupId>

+ 1 - 0
webchat-search/pom.xml

@@ -47,6 +47,7 @@
     </dependencies>
 
     <build>
+        <finalName>webchat-search</finalName>
         <plugins>
             <plugin>
                 <groupId>org.springframework.boot</groupId>

+ 1 - 0
webchat-sso/pom.xml

@@ -41,6 +41,7 @@
     </dependencies>
 
     <build>
+        <finalName>webchat-sso</finalName>
         <plugins>
             <plugin>
                 <groupId>org.springframework.boot</groupId>

+ 1 - 0
webchat-ugc/pom.xml

@@ -55,6 +55,7 @@
     </dependencies>
 
     <build>
+        <finalName>webchat-ugc</finalName>
         <plugins>
             <plugin>
                 <groupId>org.springframework.boot</groupId>

+ 3 - 0
webchat-ugc/src/main/java/com/webchat/ugc/service/redpacket/OpenRedPacketWithRedissonLockService.java

@@ -62,12 +62,15 @@ public class OpenRedPacketWithRedissonLockService extends AbstractOpenRedPacketS
         Long redPacketId = redPacket.getId();
         /**
          * 1. 读取当前红包剩余金额
+         *
+         * 10、10、10
          */
         int balanceAmount = this.getBalance(redPacketId);
         Assert.isTrue(balanceAmount > 0, "红包被瓜分完了");
 
         /**
          * 2. 获取红包当前剩余可拆分份额
+         * 2、2、2
          */
         int gradCount = this.getGradCount(redPacketId);
         Assert.isTrue(gradCount > 0, "来晚了");

+ 1 - 0
webchat-user/pom.xml

@@ -36,6 +36,7 @@
     </dependencies>
 
     <build>
+        <finalName>webchat-user</finalName>
         <plugins>
             <plugin>
                 <groupId>org.springframework.boot</groupId>

+ 1 - 1
webchat-user/src/main/java/com/webchat/user/service/relation/AccountRelationFactory.java

@@ -39,7 +39,7 @@ public class AccountRelationFactory implements InitializingBean, ApplicationCont
         services.put(RoleCodeEnum.ROBOT.getCode(), applicationContext.getBean(User2RobotAccountRelationService.class));
         services.put(RoleCodeEnum.GROUP.getCode(), applicationContext.getBean(User2GroupAccountRelationService.class));
         services.put(RoleCodeEnum.PUBLIC_ACCOUNT.getCode(), applicationContext.getBean(User2OfficialAccountRelationService.class));
-        services.put(RoleCodeEnum.FILE_ACCOUNT.getCode(), applicationContext.getBean(User2AIAgentSenderAccountRelationService.class));
+        services.put(RoleCodeEnum.AIBOT.getCode(), applicationContext.getBean(User2AIAgentSenderAccountRelationService.class));
         services.put(RoleCodeEnum.SERVER_ACCOUNT.getCode(), applicationContext.getBean(User2ServerAccountRelationService.class));
     }
 

Some files were not shown because too many files changed in this diff