Skip to content

Commit 1c825ee

Browse files
committed
chore: enhance node health checks in processors
1 parent 3d70d29 commit 1c825ee

File tree

5 files changed

+72
-6
lines changed

5 files changed

+72
-6
lines changed

package-lock.json

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@
7777
"@prisma/adapter-pg": "6.19.0",
7878
"@prisma/client": "6.19.0",
7979
"@remnawave/hashed-set": "^0.0.4",
80-
"@remnawave/node-contract": "0.6.0",
80+
"@remnawave/node-contract": "0.6.1",
8181
"@remnawave/xtls-sdk": "^0.7.0",
8282
"@scalar/nestjs-api-reference": "^1.0.8",
8383
"@simplewebauthn/server": "^13.2.2",

src/common/axios/axios.service.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ export class AxiosService {
5454
ca: jwt.caCert,
5555
checkServerIdentity: () => undefined,
5656
rejectUnauthorized: true,
57+
keepAlive: true,
5758
});
5859

5960
this.axiosInstance.defaults.httpsAgent = httpsAgent;

src/queue/_nodes/processors/start-all-nodes-by-profile.processor.ts

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,49 @@ export class StartAllNodesByProfileQueueProcessor extends WorkerHost {
152152
throw new Error('Failed to get active node inbounds tags');
153153
}
154154

155+
const xrayStatusResponse = await this.axios.getNodeHealth(node.address, node.port);
156+
157+
if (!xrayStatusResponse.isOk || !xrayStatusResponse.response) {
158+
await this.commandBus.execute(
159+
new UpdateNodeCommand({
160+
uuid: node.uuid,
161+
lastStatusMessage: xrayStatusResponse.message ?? null,
162+
lastStatusChange: new Date(),
163+
isConnected: false,
164+
isConnecting: false,
165+
usersOnline: 0,
166+
}),
167+
);
168+
169+
this.logger.error(
170+
`Pre-check failed. Node: ${node.uuid}${node.address}:${node.port}, error: ${xrayStatusResponse.message}`,
171+
);
172+
173+
return;
174+
}
175+
176+
if (
177+
xrayStatusResponse.response.nodeVersion === null ||
178+
xrayStatusResponse.response.nodeVersion === undefined
179+
) {
180+
await this.commandBus.execute(
181+
new UpdateNodeCommand({
182+
uuid: node.uuid,
183+
lastStatusMessage:
184+
'Unknown node version. Please upgrade Remnawave Node to the latest version.',
185+
lastStatusChange: new Date(),
186+
isConnected: false,
187+
isConnecting: false,
188+
usersOnline: 0,
189+
}),
190+
);
191+
192+
this.logger.error(
193+
`Node ${node.uuid} – unknown node version. Please upgrade Remnawave Node to the latest version.`,
194+
);
195+
return;
196+
}
197+
155198
const filteredInboundsHashes = config.response.hashesPayload.inbounds.filter(
156199
(inbound) => activeNodeInboundsTags.has(inbound.tag),
157200
);

src/queue/_nodes/processors/start-node.processor.ts

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ export class StartNodeProcessor extends WorkerHost {
9191
nodeEntity.port,
9292
);
9393

94-
if (!xrayStatusResponse.isOk) {
94+
if (!xrayStatusResponse.isOk || !xrayStatusResponse.response) {
9595
await this.commandBus.execute(
9696
new UpdateNodeCommand({
9797
uuid: nodeEntity.uuid,
@@ -110,6 +110,28 @@ export class StartNodeProcessor extends WorkerHost {
110110
return;
111111
}
112112

113+
if (
114+
xrayStatusResponse.response.nodeVersion === null ||
115+
xrayStatusResponse.response.nodeVersion === undefined
116+
) {
117+
await this.commandBus.execute(
118+
new UpdateNodeCommand({
119+
uuid: nodeEntity.uuid,
120+
lastStatusMessage:
121+
'Unknown node version. Please upgrade Remnawave Node to the latest version.',
122+
lastStatusChange: new Date(),
123+
isConnected: false,
124+
isConnecting: false,
125+
usersOnline: 0,
126+
}),
127+
);
128+
129+
this.logger.error(
130+
`Node ${nodeEntity.uuid} – unknown node version. Please upgrade Remnawave Node to the latest version.`,
131+
);
132+
return;
133+
}
134+
113135
const startTime = getTime();
114136
const config = await this.queryBus.execute(
115137
new GetPreparedConfigWithUsersQuery(

0 commit comments

Comments
 (0)