mirror of
https://github.com/shumaiOne/shumai.git
synced 2026-11-30 12:54:55 +00:00
fix(cli): remove unused watch import in daemon utility
This commit is contained in:
@@ -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)
|
||||||
|
|||||||
Reference in New Issue
Block a user