cli: fix error starting remote tunnels (#185701)

* untested wip

* cli: fix error starting remote tunnels

Fixes #185585

Output was prefixed which prevented the lines from being split to detect the tunnel status.
This commit is contained in:
Connor Peet 2023-06-20 14:30:07 -07:00 committed by GitHub
parent 3b49115bf9
commit ffe64dab3c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 31 additions and 6 deletions

View File

@ -101,6 +101,7 @@ function buildWin32Setup(arch, target) {
AppMutex: product.win32MutexName,
TunnelMutex: product.win32TunnelMutex,
TunnelServiceMutex: product.win32TunnelServiceMutex,
TunnelApplicationName: product.tunnelApplicationName,
ApplicationName: product.applicationName,
Arch: arch,
AppId: { 'ia32': ia32AppId, 'x64': x64AppId, 'arm64': arm64AppId }[arch],

View File

@ -1362,7 +1362,7 @@ begin
end;
end;
if IsNotBackgroundUpdate() and CheckForMutexes('{#TunnelMutex}') then
if IsNotBackgroundUpdate() and not StopTunnelProcesses() then
begin
MsgBox('{#NameShort} is still running a tunnel. Please stop the tunnel before installing.', mbInformation, MB_OK);
Result := false
@ -1380,6 +1380,30 @@ end;
var
ShouldRestartTunnelService: Boolean;
function StopTunnelProcesses();
var
WaitCounter: Integer;
TaskKilled: Integer;
begin
Log('Stopping all tunnel services with taskkill');
Exec('taskkill.exe', '/f /im "' + ExpandConstant('"{app}\bin\{#TunnelApplicationName}.exe"') + '"', '', SW_HIDE, ewWaitUntilTerminated, TaskKilled);
WaitCounter := 10;
while (WaitCounter > 0) and CheckForMutexes('{#TunnelMutex}') do
begin
Log('Tunnel process is is still running, waiting');
Sleep(500);
WaitCounter := WaitCounter - 1
end;
if CheckForMutexes('{#TunnelMutex}') then
Log('Unable to stop tunnel processes')
exit(False)
else
exit(True)
end
end;
procedure StopTunnelServiceIfNeeded();
var
StopServiceResultCode: Integer;
@ -1607,4 +1631,4 @@ begin
#endif
Exec(ExpandConstant('{sys}\icacls.exe'), ExpandConstant('"{app}" /inheritancelevel:r ') + Permissions, '', SW_HIDE, ewWaitUntilTerminated, ResultCode);
end;
end;

View File

@ -340,13 +340,13 @@ export class RemoteTunnelService extends Disposable implements IRemoteTunnelServ
}
});
if (!this.environmentService.isBuilt) {
onOutput('Building tunnel CLI from sources and run', false);
onOutput(`${logLabel} Spawning: cargo run -- tunnel ${commandArgs.join(' ')}`, false);
onOutput('Building tunnel CLI from sources and run\n', false);
onOutput(`${logLabel} Spawning: cargo run -- tunnel ${commandArgs.join(' ')}\n`, false);
tunnelProcess = spawn('cargo', ['run', '--', 'tunnel', ...commandArgs], { cwd: join(this.environmentService.appRoot, 'cli'), stdio });
} else {
onOutput('Running tunnel CLI', false);
onOutput('Running tunnel CLI\n', false);
const tunnelCommand = this.getTunnelCommandLocation();
onOutput(`${logLabel} Spawning: ${tunnelCommand} tunnel ${commandArgs.join(' ')}`, false);
onOutput(`${logLabel} Spawning: ${tunnelCommand} tunnel ${commandArgs.join(' ')}\n`, false);
tunnelProcess = spawn(tunnelCommand, ['tunnel', ...commandArgs], { cwd: homedir(), stdio });
}