mirror of
https://github.com/Start9Labs/start-os.git
synced 2026-04-04 22:39:46 +00:00
feat: Add the stop/start loop for the service
This commit is contained in:
@@ -10,9 +10,10 @@ export class Overlay {
|
||||
readonly effects: T.Effects,
|
||||
readonly imageId: string,
|
||||
readonly rootfs: string,
|
||||
readonly guid: string,
|
||||
) {}
|
||||
static async of(effects: T.Effects, imageId: string) {
|
||||
const rootfs = await effects.createOverlayedImage({ imageId })
|
||||
const [rootfs, guid] = await effects.createOverlayedImage({ imageId })
|
||||
|
||||
for (const dirPart of ["dev", "sys", "proc", "run"] as const) {
|
||||
await fs.mkdir(`${rootfs}/${dirPart}`, { recursive: true })
|
||||
@@ -23,7 +24,7 @@ export class Overlay {
|
||||
])
|
||||
}
|
||||
|
||||
return new Overlay(effects, imageId, rootfs)
|
||||
return new Overlay(effects, imageId, rootfs, guid)
|
||||
}
|
||||
|
||||
async mount(options: MountOptions, path: string): Promise<Overlay> {
|
||||
@@ -51,8 +52,9 @@ export class Overlay {
|
||||
}
|
||||
|
||||
async destroy() {
|
||||
await execFile("umount", ["-R", this.rootfs])
|
||||
await fs.rm(this.rootfs, { recursive: true, force: true })
|
||||
const imageId = this.imageId
|
||||
const guid = this.guid
|
||||
await this.effects.destroyOverlayedImage({ imageId, guid })
|
||||
}
|
||||
|
||||
async exec(
|
||||
|
||||
Reference in New Issue
Block a user