refactor: separate createSession to sessionManager

This commit is contained in:
wancat committed 2023-10-30 22:10:25 +08:00
1 parent 7843020524
commit 11bc793b12
7 files changed
+68 -49

No files matched your search

+5 -3
View File
@@ -25,17 +25,19 @@ const containerOptions = {
// const network = engine.getNetwork(config.dockerNetwork)
export async function createContainer(name) {
const container = await engine.createContainer({
export function createContainer(name) {
return engine.createContainer({
...containerOptions,
name,
})
return container
}
export async function getAndStartContainer(id) {
console.log(`Getting container: ${id}`)
const container = engine.getContainer(id)
if (!container) {
throw new Error(`Container ${id} not found`)
}
if (!(await container.inspect()).State.Running) {
await container.start()
}