fix(cli): remove unused watch import in daemon utility

This commit is contained in:
yiling
2026-06-20 12:56:15 +08:00
parent c6527650d0
commit 4bd5083ac1
+7 -8
View File
@@ -5,7 +5,6 @@ import {
readFileSync, readFileSync,
unlinkSync, unlinkSync,
mkdirSync, mkdirSync,
watch,
statSync, statSync,
createReadStream, createReadStream,
openSync, openSync,
@@ -150,9 +149,9 @@ function viewLogs(appName: string, logFile: string): void {
process.stdout.write(lastLines + '\n') process.stdout.write(lastLines + '\n')
let cursor = statSync(logFile).size let cursor = statSync(logFile).size
const watcher = watch(logFile, (event) => { const interval = setInterval(() => {
if (event === 'change') { try {
try { if (existsSync(logFile)) {
const stats = statSync(logFile) const stats = statSync(logFile)
if (stats.size > cursor) { if (stats.size > cursor) {
const stream = createReadStream(logFile, { start: cursor, end: stats.size - 1 }) const stream = createReadStream(logFile, { start: cursor, end: stats.size - 1 })
@@ -161,14 +160,14 @@ function viewLogs(appName: string, logFile: string): void {
} else if (stats.size < cursor) { } else if (stats.size < cursor) {
cursor = stats.size cursor = stats.size
} }
} catch {
// Ignore read errors
} }
} catch {
// Ignore read errors
} }
}) }, 250)
const cleanup = () => { const cleanup = () => {
watcher.close() clearInterval(interval)
process.exit(0) process.exit(0)
} }
process.on('SIGINT', cleanup) process.on('SIGINT', cleanup)