mirror of
https://github.com/Start9Labs/start-os.git
synced 2026-03-30 12:11:56 +00:00
chore: Simplify the state into one
This commit is contained in:
@@ -2,6 +2,7 @@ import { types as T, util, EmVer } from "@start9labs/start-sdk"
|
||||
import * as fs from "fs/promises"
|
||||
|
||||
import { PolyfillEffects } from "./polyfillEffects"
|
||||
import { Duration, duration } from "../../../Models/Duration"
|
||||
import { ExecuteResult, System } from "../../../Interfaces/System"
|
||||
import { matchManifest, Manifest, Procedure } from "./matchManifest"
|
||||
import { create } from "domain"
|
||||
@@ -202,7 +203,7 @@ export class SystemForEmbassy implements System {
|
||||
private async mainStop(
|
||||
effects: HostSystemStartOs,
|
||||
options?: { timeout?: number },
|
||||
): Promise<void> {
|
||||
): Promise<Duration> {
|
||||
const { currentRunning } = this
|
||||
delete this.currentRunning
|
||||
if (currentRunning) {
|
||||
@@ -210,6 +211,7 @@ export class SystemForEmbassy implements System {
|
||||
timeout: options?.timeout || this.manifest.main["sigterm-timeout"],
|
||||
})
|
||||
}
|
||||
return duration(this.manifest.main["sigterm-timeout"], "s")
|
||||
}
|
||||
private async createBackup(effects: HostSystemStartOs): Promise<void> {
|
||||
const backup = this.manifest.backup.create
|
||||
|
||||
@@ -4,6 +4,7 @@ import { string } from "ts-matches"
|
||||
import { HostSystemStartOs } from "../HostSystemStartOs"
|
||||
import { Effects } from "../../Models/Effects"
|
||||
import { RpcResult } from "../RpcListener"
|
||||
import { duration } from "../../Models/Duration"
|
||||
const LOCATION = "/usr/lib/startos/package/startos"
|
||||
export class SystemForStartOs implements System {
|
||||
private onTerm: (() => Promise<void>) | undefined
|
||||
@@ -82,7 +83,7 @@ export class SystemForStartOs implements System {
|
||||
await effects.setMainStatus({ status: "stopped" })
|
||||
if (this.onTerm) await this.onTerm()
|
||||
delete this.onTerm
|
||||
return
|
||||
return duration(30, "s")
|
||||
}
|
||||
case "/config/set": {
|
||||
const path = `${LOCATION}/procedures/config`
|
||||
|
||||
6
container-runtime/src/Models/Duration.ts
Normal file
6
container-runtime/src/Models/Duration.ts
Normal file
@@ -0,0 +1,6 @@
|
||||
export type TimeUnit = "d" | "h" | "s" | "ms"
|
||||
export type Duration = `${number}${TimeUnit}`
|
||||
|
||||
export function duration(timeValue: number, timeUnit: TimeUnit = "s") {
|
||||
return `${timeValue}${timeUnit}` as Duration
|
||||
}
|
||||
Reference in New Issue
Block a user