Skip to content

Commit

Permalink
Add in debug logs for log file
Browse files Browse the repository at this point in the history
  • Loading branch information
pflooky committed Jul 15, 2024
1 parent 025e9cb commit 7f8422f
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 12 deletions.
2 changes: 1 addition & 1 deletion badges/coverage.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
14 changes: 9 additions & 5 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

14 changes: 9 additions & 5 deletions src/insta-integration.js
Original file line number Diff line number Diff line change
Expand Up @@ -412,10 +412,8 @@ async function runApplication(
fs.mkdirSync(logsFolder)
}
try {
const logStream = fs.createWriteStream(
`${logsFolder}/app_output_${appIndex}.log`,
{ flags: 'w+' }
)
const logFile = `${logsFolder}/app_output_${appIndex}.log`
const logStream = fs.createWriteStream(logFile, { flags: 'w+' })
// Run in the background
const runApp = spawn(runConf.command, [], {
cwd: configFolder,
Expand All @@ -425,21 +423,27 @@ async function runApplication(
runApp.stderr.pipe(logStream)

if (waitForFinish) {
logger.info('Waiting for command to finish')
logger.info({
message: 'Waiting for command to finish',
command: runConf.command
})
await new Promise(resolve => {
runApp.on('close', function (code) {
logger.info(`Application ${appIndex} exited with code ${code}`)
logger.debug(fs.readFileSync(logFile).toString())
resolve()
})
})
} else {
runApp.on('close', function (code) {
logger.info(`Application ${appIndex} exited with code ${code}`)
logger.debug(fs.readFileSync(logFile).toString())
})
}
runApp.on('error', function (err) {
logger.error(`Application ${appIndex} failed with error`)
logger.error(err)
logger.debug(fs.readFileSync(logFile).toString())
throw new Error(err)
})
return { runApp, logStream }
Expand Down

0 comments on commit 7f8422f

Please sign in to comment.