Skip to content

Commit

Permalink
fix: Fix chectl logs before che pods start (#836)
Browse files Browse the repository at this point in the history
* fix chectl logs errors

Signed-off-by: Flavius Lacatusu <[email protected]>

* Fix typo

Signed-off-by: Flavius Lacatusu <[email protected]>
  • Loading branch information
flacatus authored Aug 31, 2020
1 parent 61f93e2 commit 9838d2b
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion src/commands/server/start.ts
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,18 @@ export default class Start extends Command {
}
}

/**
* Determine if a directory is empty.
*/
async isDirEmpty(dirname: string): Promise<boolean> {
try {
return fs.readdirSync(dirname).length === 0
// Fails in case if directory doesn't exist
} catch {
return true
}
}

/**
* Checks if TLS is disabled via operator custom resource.
* Returns true if TLS is enabled (or omitted) and false if it is explicitly disabled.
Expand Down Expand Up @@ -383,7 +395,6 @@ export default class Start extends Command {
if (!ctx.isCheDeployed) {
this.checkPlatformCompatibility(flags)
await platformCheckTasks.run(ctx)
this.log(`Eclipse Che logs will be available in '${ctx.directory}'`)
await logsTasks.run(ctx)
await eventTasks.run(ctx)
await installTasks.run(ctx)
Expand All @@ -402,6 +413,10 @@ export default class Start extends Command {
await postInstallTasks.run(ctx)
this.log('Command server:start has completed successfully.')
} catch (err) {
const isDirEmpty = await this.isDirEmpty(ctx.directory)
if (isDirEmpty) {
this.error(`${err}\nInstallation failed. There are no available logs.`)
}
this.error(`${err}\nInstallation failed, check logs in '${ctx.directory}'`)
}

Expand Down

0 comments on commit 9838d2b

Please sign in to comment.