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

This commit is contained in:
Jerry 2025-05-04 00:07:49 +08:00
parent 33a0cdf946
commit dc3101ae4b
2 changed files with 5 additions and 2 deletions

View File

@ -1,6 +1,8 @@
import System from '../../utils/core/system'; import System from '../../utils/core/system';
import fs from 'fs/promises'; import fs from 'fs/promises';
import logger from '../../utils/core/logger'; import logger from '../../utils/core/logger';
import path from 'path';
import paths from '../../utils/core/path';
class SystemService { class SystemService {
public async systemRestart() { public async systemRestart() {
@ -10,7 +12,8 @@ class SystemService {
public async getRestartTime() { public async getRestartTime() {
logger.debug(`有个小可爱想知道核心重启花了多久..`); logger.debug(`有个小可爱想知道核心重启花了多久..`);
return await fs.readFile('/temp/restart_time', 'utf8'); const restartTimePath = path.join(paths.get('temp'), 'restart_time');
return await fs.readFile(restartTimePath, 'utf8');
} }
} }

View File

@ -48,7 +48,7 @@ async function testGetAPI() {
async function testPostAPI() { async function testPostAPI() {
try { try {
const response = await axios.post('https://core.crystelf.top/api/system/restart', { const response = await axios.post('https://core.crystelf.top/api/system/getRestartTime', {
token: 114113, token: 114113,
}); });
console.log('[HTTP][POST] Response:', response.data); console.log('[HTTP][POST] Response:', response.data);