Skip to content

Commit 3ff7a73

Browse files
committed
close the SSH connection when the command has completed
1 parent 0d3966f commit 3ff7a73

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

src/cloud/install/installer.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,18 +41,20 @@ class CloudInstaller {
4141
debug: undefined
4242
};
4343

44-
const client = new Client();
44+
const connection = new Client();
4545
return new Promise<string>((F, R) => {
46-
client.on('ready', () => {
46+
connection.on('ready', () => {
4747
log.debug('logged into server');
48-
client.exec(INSTALL_COMMAND, (e: Error, stream: ssh2.Channel) => {
48+
connection.exec(INSTALL_COMMAND, (e: Error, stream: ssh2.Channel) => {
4949
if (e) {
50+
connection.end();
5051
R({
5152
message: 'could not execute command: ' + e.message
5253
});
5354
return;
5455
}
5556
stream.on('end', () => {
57+
connection.end();
5658
R({
5759
message: 'invitation URL not found'
5860
});
@@ -74,9 +76,9 @@ class CloudInstaller {
7476
message: 'could not login: ' + e.message
7577
});
7678
}).on('end', () => {
77-
log.debug('end');
79+
log.debug('connection end');
7880
}).on('close', (hadError: boolean) => {
79-
log.debug('close (hadError: %1)', hadError);
81+
log.debug('connection close, with%1 error', (hadError ? '' : 'out'));
8082
}).connect(connectConfig);
8183
});
8284
}

0 commit comments

Comments
 (0)