Commit 15e3db577c659039902a2df6883a56f331e2548b
1 parent
fab59a81
fix(core): remove all hardcoded port 3000 from server routes to use config.port …
…to prevent EADDRINUSE
Showing
3 changed files
with
10 additions
and
8 deletions
server/agent-server.js
| ... | ... | @@ -9,7 +9,8 @@ const cors = require('cors'); |
| 9 | 9 | const agentChatRoute = require('./routes/agent-chat'); |
| 10 | 10 | |
| 11 | 11 | const app = express(); |
| 12 | -const PORT = 3000; | |
| 12 | +const config = require('./config'); | |
| 13 | +const PORT = process.env.PORT || config.port || 3010; | |
| 13 | 14 | |
| 14 | 15 | app.use(cors({ origin: ['http://localhost:5173'], credentials: true })); |
| 15 | 16 | ... | ... |
server/routes/agent-chat.js
| ... | ... | @@ -1472,7 +1472,7 @@ router.post('/task/dispatch', async (req, res) => { |
| 1472 | 1472 | const http = require('http'); |
| 1473 | 1473 | const postData = JSON.stringify({ message: taskMessage, conversationId: executionConvId }); |
| 1474 | 1474 | const options = { |
| 1475 | - hostname: 'localhost', port: 3000, | |
| 1475 | + hostname: 'localhost', port: systemConfig.port, | |
| 1476 | 1476 | path: `/api/agent/${to}/chat`, |
| 1477 | 1477 | method: 'POST', |
| 1478 | 1478 | headers: { 'Content-Type': 'application/json', 'Content-Length': Buffer.byteLength(postData) }, |
| ... | ... | @@ -1645,7 +1645,7 @@ router.post('/task/report', (req, res) => { |
| 1645 | 1645 | const http = require('http'); |
| 1646 | 1646 | const postData = JSON.stringify({ message: callbackMessage, conversationId: callbackConvId }); |
| 1647 | 1647 | const options = { |
| 1648 | - hostname: 'localhost', port: 3000, | |
| 1648 | + hostname: 'localhost', port: systemConfig.port, | |
| 1649 | 1649 | path: `/api/agent/${to}/chat`, |
| 1650 | 1650 | method: 'POST', |
| 1651 | 1651 | headers: { 'Content-Type': 'application/json', 'Content-Length': Buffer.byteLength(postData) }, |
| ... | ... | @@ -1727,7 +1727,7 @@ router.post('/:agentId/task/transition', (req, res) => { |
| 1727 | 1727 | const http = require('http'); |
| 1728 | 1728 | const postData = JSON.stringify({ message: masterMsg, conversationId: `approval-${taskId}` }); |
| 1729 | 1729 | const options = { |
| 1730 | - hostname: 'localhost', port: 3000, | |
| 1730 | + hostname: 'localhost', port: systemConfig.port, | |
| 1731 | 1731 | path: `/api/agent/master/chat`, |
| 1732 | 1732 | method: 'POST', |
| 1733 | 1733 | headers: { 'Content-Type': 'application/json', 'Content-Length': Buffer.byteLength(postData) }, |
| ... | ... | @@ -1816,7 +1816,7 @@ ${artifactContent ? `è¿™æ˜¯ä¸Šä¸€é˜¶æ®µä½ æˆ–ä½ çš„å‰ç½®èŠ‚ç‚¹ç•™ä¸‹çš„äº¤ä»˜ç‰ |
| 1816 | 1816 | const http = require('http'); |
| 1817 | 1817 | const postData = JSON.stringify({ message: "è¯·ç¡®è®¤ä½ å·²æ”¶åˆ°ç³»ç»Ÿçš„æ–°é˜¶æ®µæŒ‚è½½æŒ‡ä»¤ï¼Œå¹¶ç«‹å³æ‰§è¡Œä½ 当å‰é˜¶æ®µæœ¬åˆ†çš„任务ï¼", conversationId: activeConvId }); |
| 1818 | 1818 | const options = { |
| 1819 | - hostname: 'localhost', port: 3000, | |
| 1819 | + hostname: 'localhost', port: systemConfig.port, | |
| 1820 | 1820 | path: `/api/agent/${agentId}/chat`, |
| 1821 | 1821 | method: 'POST', |
| 1822 | 1822 | headers: { 'Content-Type': 'application/json', 'Content-Length': Buffer.byteLength(postData) }, |
| ... | ... | @@ -1881,7 +1881,7 @@ router.post('/task/reject', (req, res) => { |
| 1881 | 1881 | const http = require('http'); |
| 1882 | 1882 | const postData = JSON.stringify({ message: rejectMessage, conversationId: `redo-${runId}-step-${stepIndex}` }); |
| 1883 | 1883 | const options = { |
| 1884 | - hostname: 'localhost', port: 3000, | |
| 1884 | + hostname: 'localhost', port: systemConfig.port, | |
| 1885 | 1885 | path: `/api/agent/${agentId}/chat`, |
| 1886 | 1886 | method: 'POST', |
| 1887 | 1887 | headers: { 'Content-Type': 'application/json', 'Content-Length': Buffer.byteLength(postData) }, |
| ... | ... | @@ -1967,7 +1967,7 @@ router.post('/human-request', (req, res) => { |
| 1967 | 1967 | const http = require('http'); |
| 1968 | 1968 | const postData = JSON.stringify({ message: masterMsg, conversationId: `human-req-${Date.now().toString(36)}` }); |
| 1969 | 1969 | const options = { |
| 1970 | - hostname: 'localhost', port: 3000, | |
| 1970 | + hostname: 'localhost', port: systemConfig.port, | |
| 1971 | 1971 | path: `/api/agent/master/chat`, |
| 1972 | 1972 | method: 'POST', |
| 1973 | 1973 | headers: { 'Content-Type': 'application/json', 'Content-Length': Buffer.byteLength(postData) }, | ... | ... |
server/services/company-heartbeat-service.js
| ... | ... | @@ -14,6 +14,7 @@ |
| 14 | 14 | const fs = require('fs'); |
| 15 | 15 | const path = require('path'); |
| 16 | 16 | const http = require('http'); |
| 17 | +const config = require('../config'); | |
| 17 | 18 | const { CompanyService } = require('./company-service'); |
| 18 | 19 | const { PipelineService } = require('./pipeline-service'); |
| 19 | 20 | const { ScheduleService } = require('./schedule-service'); |
| ... | ... | @@ -26,7 +27,7 @@ class CompanyHeartbeatService { |
| 26 | 27 | this.timers = new Map(); // companyId → NodeJS.Timeout |
| 27 | 28 | this.companyService = new CompanyService(); |
| 28 | 29 | this.scheduleService = new ScheduleService(); |
| 29 | - this.port = 3000; | |
| 30 | + this.port = config.port || 3010; | |
| 30 | 31 | this._started = false; |
| 31 | 32 | } |
| 32 | 33 | ... | ... |