@dainprotocol/tunnel 1.1.25 → 1.1.29
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/client/index.d.ts +5 -7
- package/dist/client/index.js +239 -186
- package/dist/server/index.d.ts +7 -1
- package/dist/server/index.js +365 -331
- package/dist/server/start.js +19 -0
- package/package.json +3 -2
package/dist/server/start.js
CHANGED
|
@@ -7,6 +7,15 @@ const index_1 = __importDefault(require("./index"));
|
|
|
7
7
|
const dotenv_1 = __importDefault(require("dotenv"));
|
|
8
8
|
// Load environment variables from .env file
|
|
9
9
|
dotenv_1.default.config();
|
|
10
|
+
// Handle uncaught exceptions to prevent server crashes
|
|
11
|
+
process.on('uncaughtException', (error) => {
|
|
12
|
+
console.error('[Fatal] Uncaught exception:', error);
|
|
13
|
+
// Don't exit - try to keep serving
|
|
14
|
+
});
|
|
15
|
+
process.on('unhandledRejection', (reason, promise) => {
|
|
16
|
+
console.error('[Fatal] Unhandled rejection at:', promise, 'reason:', reason);
|
|
17
|
+
// Don't exit - try to keep serving
|
|
18
|
+
});
|
|
10
19
|
const port = parseInt(process.env.PORT || '3000', 10);
|
|
11
20
|
const hostname = process.env.HOSTNAME || 'localhost';
|
|
12
21
|
const server = new index_1.default(hostname, port);
|
|
@@ -19,3 +28,13 @@ server.start()
|
|
|
19
28
|
console.error('Failed to start DainTunnel Server:', error);
|
|
20
29
|
process.exit(1);
|
|
21
30
|
});
|
|
31
|
+
// Graceful shutdown on SIGTERM (sent by App Platform)
|
|
32
|
+
process.on('SIGTERM', () => {
|
|
33
|
+
console.log('[Server] SIGTERM received, shutting down gracefully...');
|
|
34
|
+
server.stop().then(() => {
|
|
35
|
+
console.log('[Server] Graceful shutdown complete');
|
|
36
|
+
process.exit(0);
|
|
37
|
+
}).catch(() => {
|
|
38
|
+
process.exit(1);
|
|
39
|
+
});
|
|
40
|
+
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dainprotocol/tunnel",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.29",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"private": false,
|
|
@@ -13,13 +13,14 @@
|
|
|
13
13
|
"test": "jest",
|
|
14
14
|
"test:watch": "jest --watch",
|
|
15
15
|
"prepublishOnly": "npm run build && npm run build:types",
|
|
16
|
+
"start": "node dist/server/start.js",
|
|
16
17
|
"start-server": "ts-node src/server/start.ts"
|
|
17
18
|
},
|
|
18
19
|
"keywords": [],
|
|
19
20
|
"author": "Ryan",
|
|
20
21
|
"license": "ISC",
|
|
21
22
|
"dependencies": {
|
|
22
|
-
"@dainprotocol/service-sdk": "2.0.
|
|
23
|
+
"@dainprotocol/service-sdk": "2.0.75",
|
|
23
24
|
"@types/body-parser": "^1.19.5",
|
|
24
25
|
"@types/cors": "^2.8.17",
|
|
25
26
|
"@types/eventsource": "^3.0.0",
|