refactor: clean up unused code

This commit is contained in:
Justin Lin committed 2025-05-05 19:55:40 +08:00
1 parent 21ff710f83
commit 156abc044a
3 files changed
+8 -91

No files matched your search

-28
View File
@@ -1,9 +1,7 @@
import fs from 'fs/promises'
import { Duplex } from 'stream'
import Docker from 'dockerode'
import config, { getQuestImage } from '../config.js'
import logger from '../utils/logger.js'
import { connectToSSH } from './ssh.js'
const engine = new Docker()
@@ -100,32 +98,6 @@ export async function getAndStartContainer(
return container
}
export async function attachContainer(
container: Docker.Container,
{ token }: { token: string }
): Promise<Duplex> {
const containerIp = (await container.inspect()).NetworkSettings.Networks[
config.docker.network
].IPAddress
console.log('containerIp', containerIp)
let error: Error | null = null
for (let i = 0; i < 10; i++) {
try {
// eslint-disable-next-line no-await-in-loop
const stream = await connectToSSH(containerIp, { token })
return stream
} catch (err) {
error = err as Error
// eslint-disable-next-line no-await-in-loop
await new Promise((resolve) => {
setTimeout(resolve, 1000)
})
}
}
throw new Error('Failed to connect to SSH', { cause: error })
}
export async function deleteContainer(id: string) {
const container = engine.getContainer(id)
if (!container) {