Add runtime version reporting and display
This commit is contained in:
@@ -3,6 +3,7 @@ import http from 'node:http';
|
||||
import path from 'node:path';
|
||||
import { settings } from './config.js';
|
||||
import { createSingboxRuntime } from './singboxRuntime.js';
|
||||
import { buildVersionInfo } from './version.js';
|
||||
|
||||
const socketPath = settings.dataplaneSocket;
|
||||
const runtime = createSingboxRuntime({
|
||||
@@ -10,6 +11,7 @@ const runtime = createSingboxRuntime({
|
||||
gateway: true,
|
||||
tproxyChain: settings.tproxyChain,
|
||||
});
|
||||
const versionInfo = buildVersionInfo('gateway');
|
||||
let ready = false;
|
||||
|
||||
function sendJson(res, statusCode, payload) {
|
||||
@@ -22,6 +24,8 @@ const server = http.createServer(async (req, res) => {
|
||||
if (req.method === 'GET' && req.url === '/status') {
|
||||
return sendJson(res, ready ? 200 : 503, {
|
||||
...await runtime.refresh(),
|
||||
gatewayBackendVersion: versionInfo.components.gatewayBackend,
|
||||
singBoxVersion: versionInfo.runtime.singBox,
|
||||
ready,
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user