feat: 重构项目心跳为Redis LIST并更新相关文档
重构项目心跳数据结构为Redis LIST,更新相关文档和OpenSpec规范。主要变更包括: - 将项目心跳从STRING改为LIST类型 - 更新后端服务以支持LIST操作 - 同步更新文档和OpenSpec规范 - 统一后端端口为3001 - 添加部署指南和Windows部署文档 修复前端API请求路径,移除硬编码的localhost地址。添加PM2和Nginx配置文件模板,完善部署流程文档。更新Redis集成协议文档,明确LIST数据结构和外部项目对接规范。
This commit is contained in:
@@ -1,34 +1,35 @@
|
||||
# Command Capability Specification
|
||||
|
||||
## Overview
|
||||
This specification defines the command capability for the BLS Project Console, which allows users to send console commands to Redis queues for other programs to read and execute.
|
||||
This specification defines the command capability for the BLS Project Console, which allows users to send console commands to target project HTTP APIs.
|
||||
|
||||
## Requirements
|
||||
|
||||
### Requirement: Command Sending to Redis
|
||||
The system SHALL send commands to a Redis queue.
|
||||
The system SHALL send commands to a target project's HTTP API.
|
||||
|
||||
#### Scenario: Sending a command to Redis queue
|
||||
#### Scenario: Sending a command to target project API
|
||||
- **WHEN** the user enters a command in the console
|
||||
- **AND** clicks the "Send" button
|
||||
- **THEN** the command SHALL be sent to the Redis queue
|
||||
- **AND** the user SHALL receive a success confirmation
|
||||
- **THEN** the backend SHALL resolve `apiBaseUrl` from the project's heartbeat
|
||||
- **AND** it SHALL call `POST {apiBaseUrl}/{apiName}` with a structured payload
|
||||
- **AND** the user SHALL receive a success confirmation if upstream returns 2xx
|
||||
|
||||
### Requirement: Command Validation
|
||||
The system SHALL validate commands before sending them to Redis.
|
||||
The system SHALL validate commands before sending them to target project API.
|
||||
|
||||
#### Scenario: Validating an empty command
|
||||
- **WHEN** the user tries to send an empty command
|
||||
- **THEN** the system SHALL display an error message
|
||||
- **AND** the command SHALL NOT be sent to Redis
|
||||
- **AND** the command SHALL NOT be sent
|
||||
|
||||
#### Scenario: Validating a command with invalid characters
|
||||
- **WHEN** the user tries to send a command with invalid characters
|
||||
- **THEN** the system SHALL display an error message
|
||||
- **AND** the command SHALL NOT be sent to Redis
|
||||
- **AND** the command SHALL NOT be sent
|
||||
|
||||
### Requirement: Command History
|
||||
The system SHALL maintain a history of sent commands.
|
||||
The system SHALL maintain a history of sent commands in the console UI.
|
||||
|
||||
#### Scenario: Viewing command history
|
||||
- **WHEN** the user opens the command history
|
||||
@@ -36,12 +37,11 @@ The system SHALL maintain a history of sent commands.
|
||||
- **AND** the user SHALL be able to select a command from the history to resend
|
||||
|
||||
### Requirement: Command Response Handling
|
||||
The system SHALL handle responses from commands sent to Redis.
|
||||
The system SHALL handle responses from commands sent to target project API.
|
||||
|
||||
#### Scenario: Receiving a command response
|
||||
- **WHEN** a command response is received from Redis
|
||||
- **THEN** the system SHALL display the response in the console
|
||||
- **AND** the response SHALL be associated with the original command
|
||||
- **WHEN** the target project API responds
|
||||
- **THEN** the system SHALL display the response status in the console
|
||||
|
||||
## Data Model
|
||||
|
||||
|
||||
@@ -1,18 +1,17 @@
|
||||
# Logging Capability Specification
|
||||
|
||||
## Overview
|
||||
This specification defines the logging capability for the BLS Project Console, which allows the system to read log records from Redis queues and display them in the console interface.
|
||||
This specification defines the logging capability for the BLS Project Console, which allows the system to read log records from Redis lists and display them in the console interface.
|
||||
|
||||
## Requirements
|
||||
|
||||
### Requirement: Log Reading from Redis
|
||||
The system SHALL read log records from a Redis queue.
|
||||
The system SHALL read log records from a Redis LIST `${projectName}_项目控制台`.
|
||||
|
||||
#### Scenario: Reading logs from Redis queue
|
||||
- **WHEN** the server starts
|
||||
- **THEN** it SHALL establish a connection to the Redis queue
|
||||
- **AND** it SHALL begin listening for new log records
|
||||
- **AND** it SHALL store log records in memory for display
|
||||
#### Scenario: Reading logs by polling
|
||||
- **WHEN** the user is viewing a project console
|
||||
- **THEN** the system SHALL read the latest log entries via `LRANGE`
|
||||
- **AND** it SHALL return logs in a user-friendly structure
|
||||
|
||||
### Requirement: Log Display in Console
|
||||
The system SHALL display log records in a user-friendly format.
|
||||
@@ -83,7 +82,3 @@ The system SHALL automatically refresh logs in real-time.
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### GET /api/logs/live
|
||||
- **Description**: Establish a WebSocket connection for real-time log updates
|
||||
- **Response**: Continuous stream of log records
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
# Redis Connection Capability Specification
|
||||
|
||||
## Overview
|
||||
This specification defines the Redis connection capability for the BLS Project Console, which manages the connection between the system and the Redis server for reading logs and sending commands.
|
||||
This specification defines the Redis connection capability for the BLS Project Console, which manages the connection between the system and the Redis server for reading logs and retrieving project heartbeats.
|
||||
|
||||
## Requirements
|
||||
|
||||
@@ -20,6 +20,7 @@ The system SHALL allow configuration of Redis connection parameters.
|
||||
- **WHEN** the server starts with Redis environment variables set
|
||||
- **THEN** it SHALL use those variables to configure the Redis connection
|
||||
- **AND** it SHALL override default values
|
||||
- **AND** it SHALL use Redis database 15
|
||||
|
||||
### Requirement: Redis Connection Reconnection
|
||||
The system SHALL automatically reconnect to Redis if the connection is lost.
|
||||
@@ -47,6 +48,15 @@ The system SHALL monitor the Redis connection status.
|
||||
- **THEN** the system SHALL update the connection status in the UI
|
||||
- **AND** it SHALL log the status change
|
||||
|
||||
### Requirement: Project Heartbeat List Retrieval
|
||||
The system SHALL read project heartbeats from Redis key `项目心跳` stored as a LIST.
|
||||
|
||||
#### Scenario: Reading projects list from Redis LIST
|
||||
- **WHEN** the client requests the projects list
|
||||
- **THEN** the system SHALL read `LRANGE 项目心跳 0 -1`
|
||||
- **AND** it SHALL parse each list element as JSON heartbeat record
|
||||
- **AND** it SHALL deduplicate by `projectName` and keep the latest `lastActiveAt`
|
||||
|
||||
## Data Model
|
||||
|
||||
### Redis Connection Configuration
|
||||
@@ -139,3 +149,9 @@ The system SHALL monitor the Redis connection status.
|
||||
"deleteOldKeys": false
|
||||
}
|
||||
```
|
||||
|
||||
## Redis Data Structures
|
||||
|
||||
### Key: 项目心跳
|
||||
- **Type**: LIST
|
||||
- **Element**: JSON string `{"projectName":"...","apiBaseUrl":"...","lastActiveAt":1768566165572}`
|
||||
|
||||
Reference in New Issue
Block a user