fix(mpc-system): 修复服务 gRPC/HTTP 端口冲突
问题: - session-coordinator 和 message-router 都默认使用 gRPC 50051 - 端口冲突导致 message-router 无法启动 - server-party 因无法连接 message-router 而失败 修复: 为每个服务分配独立的端口: - account-service: HTTP 8080 - session-coordinator: gRPC 50051, HTTP 8081 - message-router: gRPC 50052, HTTP 8082 - server-party-1: HTTP 8083 - server-party-2: HTTP 8084 - server-party-3: HTTP 8085 服务器修复步骤: git pull sudo bash scripts/deploy.sh build # 重新生成 systemd 服务文件 sudo bash scripts/deploy.sh restart sudo bash scripts/deploy.sh status 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
parent
959fc3910c
commit
ec9366186c
|
|
@ -267,11 +267,12 @@ create_systemd_services() {
|
|||
log_info "Creating systemd service files..."
|
||||
|
||||
# Common service template
|
||||
# Args: SERVICE_NAME, DESCRIPTION, EXEC_START, EXTRA_ENV (optional)
|
||||
create_service_file() {
|
||||
local SERVICE_NAME=$1
|
||||
local DESCRIPTION=$2
|
||||
local EXEC_START=$3
|
||||
local PARTY_ID=$4
|
||||
local EXTRA_ENV=$4
|
||||
|
||||
cat > "/etc/systemd/system/$SERVICE_NAME.service" << EOF
|
||||
[Unit]
|
||||
|
|
@ -285,7 +286,7 @@ User=$MPC_USER
|
|||
Group=$MPC_GROUP
|
||||
WorkingDirectory=$MPC_HOME
|
||||
EnvironmentFile=$CONFIG_DIR/mpc.env
|
||||
${PARTY_ID:+Environment=PARTY_ID=$PARTY_ID}
|
||||
${EXTRA_ENV:+$EXTRA_ENV}
|
||||
ExecStart=$EXEC_START
|
||||
Restart=always
|
||||
RestartSec=5
|
||||
|
|
@ -303,13 +304,34 @@ WantedBy=multi-user.target
|
|||
EOF
|
||||
}
|
||||
|
||||
# Create service files
|
||||
create_service_file "mpc-account" "Account Service" "$BIN_DIR/account-service"
|
||||
create_service_file "mpc-session-coordinator" "Session Coordinator" "$BIN_DIR/session-coordinator"
|
||||
create_service_file "mpc-message-router" "Message Router" "$BIN_DIR/message-router"
|
||||
create_service_file "mpc-server-party-1" "Server Party 1" "$BIN_DIR/server-party" "server-party-1"
|
||||
create_service_file "mpc-server-party-2" "Server Party 2" "$BIN_DIR/server-party" "server-party-2"
|
||||
create_service_file "mpc-server-party-3" "Server Party 3" "$BIN_DIR/server-party" "server-party-3"
|
||||
# Create service files with different gRPC ports to avoid conflicts
|
||||
# session-coordinator: gRPC 50051, HTTP 8081
|
||||
# message-router: gRPC 50052, HTTP 8082
|
||||
# server-party-1/2/3: HTTP 8083/8084/8085
|
||||
# account-service: HTTP 8080
|
||||
|
||||
create_service_file "mpc-account" "Account Service" "$BIN_DIR/account-service" \
|
||||
"Environment=MPC_SERVER_HTTP_PORT=8080"
|
||||
|
||||
create_service_file "mpc-session-coordinator" "Session Coordinator" "$BIN_DIR/session-coordinator" \
|
||||
"Environment=MPC_SERVER_GRPC_PORT=50051
|
||||
Environment=MPC_SERVER_HTTP_PORT=8081"
|
||||
|
||||
create_service_file "mpc-message-router" "Message Router" "$BIN_DIR/message-router" \
|
||||
"Environment=MPC_SERVER_GRPC_PORT=50052
|
||||
Environment=MPC_SERVER_HTTP_PORT=8082"
|
||||
|
||||
create_service_file "mpc-server-party-1" "Server Party 1" "$BIN_DIR/server-party" \
|
||||
"Environment=PARTY_ID=server-party-1
|
||||
Environment=MPC_SERVER_HTTP_PORT=8083"
|
||||
|
||||
create_service_file "mpc-server-party-2" "Server Party 2" "$BIN_DIR/server-party" \
|
||||
"Environment=PARTY_ID=server-party-2
|
||||
Environment=MPC_SERVER_HTTP_PORT=8084"
|
||||
|
||||
create_service_file "mpc-server-party-3" "Server Party 3" "$BIN_DIR/server-party" \
|
||||
"Environment=PARTY_ID=server-party-3
|
||||
Environment=MPC_SERVER_HTTP_PORT=8085"
|
||||
|
||||
# Reload systemd
|
||||
systemctl daemon-reload
|
||||
|
|
|
|||
Loading…
Reference in New Issue