| | |
| | | const { UploadManager } = require("./lib/upload"); |
| | | const { createDashboard } = require("./dashboard/server"); |
| | | |
| | | const configPath = path.join(__dirname, "config.json"); |
| | | // 配置读取:优先从工作目录(CWD),便于打包后用户编辑;开发时回退到 __dirname |
| | | let configPath = path.resolve(process.cwd(), "config.json"); |
| | | if (!fs.existsSync(configPath)) { |
| | | console.error("缺少 config.json,请先创建配置文件"); |
| | | configPath = path.join(__dirname, "config.json"); |
| | | } |
| | | if (!fs.existsSync(configPath)) { |
| | | console.error("缺少 config.json,请先创建配置文件(放置于当前工作目录或程序目录)"); |
| | | process.exit(1); |
| | | } |
| | | |
| | |
| | | const activeDevices = config.devices.filter((d) => d.enabled !== false); |
| | | console.log(`配置校验通过: ${activeDevices.length}/${config.devices.length} 台设备启用`); |
| | | |
| | | const logDir = path.resolve(__dirname, config.logDir || "./logs"); |
| | | const logDir = path.resolve(process.cwd(), config.logDir || "./logs"); |
| | | const logger = createLogger({ |
| | | logDir, |
| | | retentionDays: config.logRetentionDays || 30, |