Skip to content

Commit

Permalink
feat: keep Kaoto backend output log available when Kaoto backend (K…
Browse files Browse the repository at this point in the history
…aotoIO#107)

native executable cannot be launched.

It allows to have more information what can be the issue.

Signed-off-by: Aurélien Pupier <apupier@redhat.com>

Signed-off-by: Aurélien Pupier <apupier@redhat.com>
  • Loading branch information
apupier authored Dec 7, 2022
1 parent d552250 commit 7ce3f0f
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 6 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# 0.3.0

- Keep `Kaoto backend` output log available when Kaoto backend native executable cannot be launched. It allows to have more information what can be the issue.

# 0.2.0

- Technical version to be able to push on Marketplace
Expand Down
21 changes: 15 additions & 6 deletions src/extension/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,25 +30,30 @@ let backendProxy: VsCodeBackendProxy;
let telemetryService: TelemetryService;

let backendProcess: child_process.ChildProcessWithoutNullStreams | undefined;
let kaotoBackendOutputChannel: vscode.OutputChannel | undefined;

export async function activate(context: vscode.ExtensionContext) {
console.info("Kaoto Editor extension is alive.");

const kaotoBackendOutputChannel = vscode.window.createOutputChannel(`Kaoto backend`);
kaotoBackendOutputChannel = vscode.window.createOutputChannel(`Kaoto backend`);
const nativeExecutable = context.asAbsolutePath(path.join("binaries", getBinaryName()));
backendProcess = child_process.spawn(nativeExecutable);
backendProcess.on("close", (code, signal) => {
if (kaotoBackendOutputChannel) {
kaotoBackendOutputChannel.dispose();
kaotoBackendOutputChannel.append(`Kaoto backend process closed with code: ${code}`);
}
});
backendProcess.stdout.on("error", function(error) {
kaotoBackendOutputChannel.append(`Failed to start Kaoto backend ${error.name} ${error.message}`);
if (kaotoBackendOutputChannel) {
kaotoBackendOutputChannel.append(`Failed to start Kaoto backend ${error.name} ${error.message}`);
}
});
backendProcess.stdout.on("data", function(data) {
const dec = new TextDecoder("utf-8");
const text = dec.decode(data);
kaotoBackendOutputChannel.append(text);
if (kaotoBackendOutputChannel) {
const dec = new TextDecoder("utf-8");
const text = dec.decode(data);
kaotoBackendOutputChannel.append(text);
}
});

const backendI18n = new I18n(backendI18nDefaults, backendI18nDictionaries, vscode.env.language);
Expand Down Expand Up @@ -91,5 +96,9 @@ export function deactivate() {
}
backendProxy?.stopServices();

if (kaotoBackendOutputChannel != undefined) {
kaotoBackendOutputChannel.dispose();
kaotoBackendOutputChannel = undefined;
}
telemetryService.sendShutdownEvent();
}

0 comments on commit 7ce3f0f

Please sign in to comment.