Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: catch logs writing errors #237

Merged
merged 1 commit into from
Aug 1, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions src/launcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ async function launchBee(abortController?: AbortController) {
return runProcess(getPath(getBeeExecutable()), ['start', `--config=${configPath}`], abortController)
}

async function runProcess(command: string, args: string[], abortController: AbortController): Promise<number> {
async function runProcess(command: string, args: string[], abortController: AbortController): Promise<void> {
return new Promise((resolve, reject) => {
const subprocess = spawn(command, args, { signal: abortController.signal, killSignal: 'SIGINT' })

Expand All @@ -144,14 +144,16 @@ async function runProcess(command: string, args: string[], abortController: Abor
create_symlink: true,
symlink_name: 'bee.current.log',
})
fileStream.on('error', err => logger.error(err))

subprocess.stdout.pipe(fileStream)
subprocess.stderr.pipe(fileStream)

subprocess.on('close', code => {
if (code === 0) {
resolve(code)
resolve()
} else {
reject(code)
reject(`process exited with non-zero status code: ${code}`)
}
})
subprocess.on('error', error => {
Expand Down