Skip to content

Commit 5bdcaee

Browse files
committed
feat: integrate supervisord-nestjs for process management
- Added @remnawave/supervisord-nestjs package to package.json and package-lock.json. - Configured SupervisordNestjsModule in app.module.ts for process management. - Updated supervisord.conf to include inet_http_server settings for remote access. - Refactored XrayService to utilize supervisord-nestjs for process control, replacing direct supervisorctl commands. - Enhanced error handling and logging for process management operations.
1 parent cc7bccf commit 5bdcaee

File tree

8 files changed

+250
-33
lines changed

8 files changed

+250
-33
lines changed
Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
name: Build & Push Pre-Dev Image
2+
3+
on:
4+
push:
5+
branches:
6+
- supervisord
7+
8+
jobs:
9+
send-tg-msg:
10+
name: Send TG message
11+
runs-on: ubuntu-latest
12+
steps:
13+
- name: Checkout source code
14+
uses: actions/checkout@v2
15+
16+
- name: Send Telegram message
17+
uses: proDreams/actions-telegram-notifier@main
18+
with:
19+
token: ${{ secrets.TELEGRAM_TOKEN }}
20+
chat_id: ${{ secrets.TELEGRAM_CHAT_ID }}
21+
thread_id: ${{ secrets.TELEGRAM_TOPIC_ID }}
22+
status: pending
23+
notify_fields: 'repo_with_tag,commit,workflow'
24+
title: 'Building docker image.'
25+
26+
build-docker-image:
27+
runs-on: ubuntu-latest
28+
steps:
29+
- name: Checkout
30+
uses: actions/checkout@v3
31+
32+
- name: Set up QEMU
33+
uses: docker/setup-qemu-action@v2
34+
35+
- name: Setup Node
36+
uses: actions/setup-node@v4
37+
with:
38+
node-version: '22.x'
39+
40+
- name: Set up Docker Buildx
41+
uses: docker/setup-buildx-action@v2
42+
43+
- name: Login to Docker Hub
44+
uses: docker/login-action@v2
45+
with:
46+
username: ${{ secrets.DOCKERHUB_USERNAME }}
47+
password: ${{ secrets.DOCKERHUB_TOKEN }}
48+
49+
- name: Build and push
50+
uses: docker/build-push-action@v3
51+
with:
52+
context: .
53+
platforms: linux/amd64,linux/arm64
54+
push: true
55+
tags: |
56+
remnawave/node:supervisord
57+
58+
send-finish-tg-msg:
59+
name: Send TG message
60+
needs: [build-docker-image]
61+
runs-on: ubuntu-latest
62+
steps:
63+
- name: Checkout source code
64+
uses: actions/checkout@v2
65+
66+
- name: Send Telegram message
67+
uses: proDreams/actions-telegram-notifier@main
68+
with:
69+
token: ${{ secrets.TELEGRAM_TOKEN }}
70+
chat_id: ${{ secrets.TELEGRAM_CHAT_ID }}
71+
thread_id: ${{ secrets.TELEGRAM_TOPIC_ID }}
72+
status: ${{ job.status }}
73+
notify_fields: 'repo_with_tag,commit,workflow'
74+
title: 'Build Pre-Dev finished.'
75+
76+
notify-on-error:
77+
runs-on: ubuntu-latest
78+
needs: [build-docker-image]
79+
if: failure()
80+
steps:
81+
- name: Checkout source code
82+
uses: actions/checkout@v2
83+
84+
- name: Send error notification
85+
uses: proDreams/actions-telegram-notifier@main
86+
with:
87+
token: ${{ secrets.TELEGRAM_TOKEN }}
88+
chat_id: ${{ secrets.TELEGRAM_CHAT_ID }}
89+
thread_id: ${{ secrets.TELEGRAM_TOPIC_ID }}
90+
status: failure
91+
notify_fields: 'repo_with_tag,commit,workflow'
92+
title: 'Build Pre-Dev failed.'

package-lock.json

Lines changed: 80 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: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
"@nestjs/platform-express": "11.0.12",
3737
"@remnawave/xtls-sdk": "0.3.0",
3838
"@remnawave/xtls-sdk-nestjs": "0.2.2",
39+
"@remnawave/supervisord-nestjs": "0.1.1",
3940
"enhanced-ms": "^4.1.0",
4041
"helmet": "^8.1.0",
4142
"husky": "9.1.7",
@@ -44,6 +45,7 @@
4445
"nest-winston": "^1.10.2",
4546
"nestjs-zod": "4.3.1",
4647
"node-object-hash": "^3.1.1",
48+
"node-supervisord": "^1.0.6-rc.2",
4749
"object-hash": "^3.0.0",
4850
"passport": "0.7.0",
4951
"passport-jwt": "4.0.1",
@@ -66,7 +68,7 @@
6668
"@types/jsonwebtoken": "^9.0.9",
6769
"@types/mjml": "^4.7.4",
6870
"@types/morgan": "^1.9.9",
69-
"@types/node": "^22.13.13",
71+
"@types/node": "^22.13.14",
7072
"@types/nunjucks": "^3.2.6",
7173
"@types/object-hash": "^3.0.6",
7274
"@types/passport-jwt": "^4.0.1",

src/app.module.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { ConfigModule, ConfigService } from '@nestjs/config';
22
import { Module } from '@nestjs/common';
33
import { JwtModule } from '@nestjs/jwt';
44

5+
import { SupervisordNestjsModule } from '@remnawave/supervisord-nestjs';
56
import { XtlsSdkNestjsModule } from '@remnawave/xtls-sdk-nestjs';
67

78
import { JwtStrategy } from '@common/guards/jwt-guards/strategies/validate-token';
@@ -28,6 +29,17 @@ import { InternalModule } from './modules/internal/internal.module';
2829
port: configService.getOrThrow<string>('XTLS_PORT'),
2930
}),
3031
}),
32+
SupervisordNestjsModule.forRootAsync({
33+
imports: [],
34+
inject: [],
35+
useFactory: () => ({
36+
host: 'http://localhost:61002',
37+
options: {
38+
username: 'remnawave',
39+
password: 'glcmYQLRwPXDXIBq',
40+
},
41+
}),
42+
}),
3143
RemnawaveNodeModules,
3244
InternalModule,
3345
JwtModule.registerAsync(getJWTConfig()),

src/modules/handler/handler.service.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1+
import { Injectable, Logger } from '@nestjs/common';
2+
13
import { RemoveUserResponseModel as RemoveUserResponseModelFromSdk } from '@remnawave/xtls-sdk/build/src/handler/models/remove-user';
24
import { AddUserResponseModel as AddUserResponseModelFromSdk } from '@remnawave/xtls-sdk/build/src/handler/models/add-user';
35
import { ISdkResponse } from '@remnawave/xtls-sdk/build/src/common/types';
46
import { InjectXtls } from '@remnawave/xtls-sdk-nestjs';
5-
import { Injectable, Logger } from '@nestjs/common';
67
import { XtlsApi } from '@remnawave/xtls-sdk';
78

89
import { ICommandResponse } from '@common/types/command-response.type';

src/modules/vision/vision.service.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1-
import { InjectXtls } from '@remnawave/xtls-sdk-nestjs';
1+
import objectHash from 'object-hash';
2+
23
import { Injectable, Logger } from '@nestjs/common';
4+
5+
import { InjectXtls } from '@remnawave/xtls-sdk-nestjs';
36
import { XtlsApi } from '@remnawave/xtls-sdk';
4-
import objectHash from 'object-hash';
57

68
import { ICommandResponse } from '@common/types/command-response.type';
79
import { ERRORS } from '@libs/contracts/constants/errors';

0 commit comments

Comments
 (0)