修复restart临时文件在Linux上的路径问题

This commit is contained in:
Jerry 2025-05-04 00:00:40 +08:00
parent 683df58d12
commit 33a0cdf946
3 changed files with 9 additions and 7 deletions

View File

@ -74,7 +74,8 @@ const apps = {
//logger.info(duration); //logger.info(duration);
if (duration) { if (duration) {
logger.warn(`重启完成!耗时 ${duration} 秒..`); logger.warn(`重启完成!耗时 ${duration} 秒..`);
fs.writeFileSync('/temp/restart_time', duration.toString()); const restartTimePath = path.join(paths.get('temp'), 'restart_time');
fs.writeFileSync(restartTimePath, duration.toString());
} }
logger.info('晶灵核心初始化完毕!'); logger.info('晶灵核心初始化完毕!');

View File

@ -3,6 +3,7 @@ import logger from './utils/core/logger';
import config from './utils/core/config'; import config from './utils/core/config';
import redis from './services/redis/redis'; import redis from './services/redis/redis';
import autoUpdater from './utils/core/autoUpdater'; import autoUpdater from './utils/core/autoUpdater';
import System from './utils/core/system';
config.check(['PORT', 'DEBUG', 'RD_PORT', 'RD_ADD', 'WS_SECRET', 'WS_PORT']); config.check(['PORT', 'DEBUG', 'RD_PORT', 'RD_ADD', 'WS_SECRET', 'WS_PORT']);
const PORT = config.get('PORT') || 3000; const PORT = config.get('PORT') || 3000;
@ -15,7 +16,8 @@ apps
}); });
const isUpdated = await autoUpdater.checkForUpdates(); const isUpdated = await autoUpdater.checkForUpdates();
if (isUpdated) { if (isUpdated) {
logger.warn(`检测到更新,请重启..`); logger.warn(`检测到更新,正在重启..`);
await System.restart();
} }
}) })
.catch((err) => { .catch((err) => {

View File

@ -1,8 +1,8 @@
import WebSocket from 'ws'; import WebSocket from 'ws';
import axios from 'axios'; import axios from 'axios';
const WS_URL = 'ws://127.0.0.1:4001'; const WS_URL = 'ws://server.crystelf.top:4001';
const WS_SECRET = '114514'; const WS_SECRET = '520520';
const CLIENT_ID = 'test'; const CLIENT_ID = 'test';
function createWebSocketClient() { function createWebSocketClient() {
@ -48,8 +48,8 @@ async function testGetAPI() {
async function testPostAPI() { async function testPostAPI() {
try { try {
const response = await axios.post('http://localhost:4000/api/system/getRestartTime', { const response = await axios.post('https://core.crystelf.top/api/system/restart', {
token: 54188, token: 114113,
}); });
console.log('[HTTP][POST] Response:', response.data); console.log('[HTTP][POST] Response:', response.data);
} catch (err) { } catch (err) {
@ -61,7 +61,6 @@ async function main() {
createWebSocketClient(); createWebSocketClient();
setTimeout(() => { setTimeout(() => {
testGetAPI();
testPostAPI(); testPostAPI();
}, 1000); }, 1000);
} }