Skip to content

Commit

Permalink
Use 64 exit code for CLI related errors. Close kbnServer if it fa…
Browse files Browse the repository at this point in the history
…iled to start.
  • Loading branch information
azasypkin committed Aug 1, 2018
1 parent 7ecbeee commit 0b5e7be
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/core/cli/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ Specify --help for available options
`);
}

process.exit(reason === undefined ? 0 : 1);
process.exit(reason === undefined ? 0 : 64);
};

export const parseArgv = (argv: string[]): Arguments => {
Expand Down
2 changes: 1 addition & 1 deletion src/core/cli/commands/serve.ts
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ function handleServeCommand(cliArgs: Arguments, installationFeatures: Installati
console.error(`\n${chalk.bgRed(chalk.white(' ERROR '))} ${reason}\n`);
}

process.exit(reason === undefined ? 0 : 1);
process.exit(reason === undefined ? 0 : (reason as any).processExitCode || 1);
},
}
);
Expand Down
7 changes: 6 additions & 1 deletion src/core/server/legacy_compat/legacy_service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,12 @@ export class LegacyService implements CoreService {
require(REPL_PATH).startRepl(this.kbnServer);
}

await kbnServer.listen();
try {
await kbnServer.listen();
} catch (err) {
await kbnServer.close();
throw err;
}

return kbnServer;
}
Expand Down

0 comments on commit 0b5e7be

Please sign in to comment.