alwaysai
Version:
The alwaysAI command-line interface (CLI)
18 lines (15 loc) • 568 B
text/typescript
import { CliTerseError } from '@alwaysai/alwayscli';
import delay = require('delay');
import { SshSpawner } from './spawner';
const TEN_SECONDS = 10 * 1000;
export const TIMED_OUT_CONNECTING_TO = 'Timed out connecting to';
export async function connectBySsh(props: { targetHostname: string }) {
const { targetHostname } = props;
const spawner = SshSpawner({ targetHostname });
await Promise.race([
spawner.run({ exe: 'echo' }),
delay.reject(TEN_SECONDS, {
value: new CliTerseError(`${TIMED_OUT_CONNECTING_TO} "${targetHostname}"`)
})
]);
}