Merge branch 'next/minor' of github.com:Start9Labs/start-os into rebase/feat/domains

This commit is contained in:
Matt Hill
2024-03-30 21:14:53 -06:00
191 changed files with 1789 additions and 1316 deletions

View File

@@ -4,5 +4,5 @@ bundle.js
startInit.js
service/
service.js
alpine.squashfs
*.squashfs
/tmp

View File

@@ -9,10 +9,11 @@ VERSION=3.19
ARCH=${ARCH:-$(uname -m)}
FLAVOR=default
if [ "$ARCH" = "x86_64" ]; then
ARCH=amd64
elif [ "$ARCH" = "aarch64" ]; then
ARCH=arm64
_ARCH=$ARCH
if [ "$_ARCH" = "x86_64" ]; then
_ARCH=amd64
elif [ "$_ARCH" = "aarch64" ]; then
_ARCH=arm64
fi
curl https://images.linuxcontainers.org/$(curl --silent https://images.linuxcontainers.org/meta/1.0/index-system | grep "^$DISTRO;$VERSION;$ARCH;$FLAVOR;" | head -n1 | sed 's/^.*;//g')/rootfs.squashfs --output alpine.squashfs
curl https://images.linuxcontainers.org/$(curl --silent https://images.linuxcontainers.org/meta/1.0/index-system | grep "^$DISTRO;$VERSION;$_ARCH;$FLAVOR;" | head -n1 | sed 's/^.*;//g')/rootfs.squashfs --output alpine.${ARCH}.squashfs

View File

@@ -112,8 +112,9 @@ export class MainLoop {
])
if (executed.exitCode === 59) {
await effects.setHealth({
name: healthId,
status: "disabled",
id: healthId,
name: value.name,
result: "disabled",
message:
executed.stderr.toString() || executed.stdout.toString(),
})
@@ -121,8 +122,9 @@ export class MainLoop {
}
if (executed.exitCode === 60) {
await effects.setHealth({
name: healthId,
status: "starting",
id: healthId,
name: value.name,
result: "starting",
message:
executed.stderr.toString() || executed.stdout.toString(),
})
@@ -130,8 +132,9 @@ export class MainLoop {
}
if (executed.exitCode === 61) {
await effects.setHealth({
name: healthId,
status: "warning",
id: healthId,
name: value.name,
result: "loading",
message:
executed.stderr.toString() || executed.stdout.toString(),
})
@@ -141,15 +144,17 @@ export class MainLoop {
const message = executed.stdout.toString()
if (!!errorMessage) {
await effects.setHealth({
name: healthId,
status: "failure",
id: healthId,
name: value.name,
result: "failure",
message: errorMessage,
})
return
}
await effects.setHealth({
name: healthId,
status: "passing",
id: healthId,
name: value.name,
result: "success",
message,
})
return
@@ -159,9 +164,10 @@ export class MainLoop {
const method = moduleCode.health?.[healthId]
if (!method) {
await effects.setHealth({
name: healthId,
status: "failure",
message: `Expecting that thejs health check ${healthId} exists`,
id: healthId,
name: value.name,
result: "failure",
message: `Expecting that the js health check ${healthId} exists`,
})
return
}
@@ -173,24 +179,27 @@ export class MainLoop {
if ("result" in result) {
await effects.setHealth({
id: healthId,
name: value.name,
result: "success",
message: null,
name: healthId,
status: "passing",
})
return
}
if ("error" in result) {
await effects.setHealth({
name: healthId,
status: "failure",
id: healthId,
name: value.name,
result: "failure",
message: result.error,
})
return
}
if (!("error-code" in result)) {
await effects.setHealth({
name: healthId,
status: "failure",
id: healthId,
name: value.name,
result: "failure",
message: `Unknown error type ${JSON.stringify(result)}`,
})
return
@@ -198,32 +207,36 @@ export class MainLoop {
const [code, message] = result["error-code"]
if (code === 59) {
await effects.setHealth({
name: healthId,
status: "disabled",
id: healthId,
name: value.name,
result: "disabled",
message,
})
return
}
if (code === 60) {
await effects.setHealth({
name: healthId,
status: "starting",
id: healthId,
name: value.name,
result: "starting",
message,
})
return
}
if (code === 61) {
await effects.setHealth({
name: healthId,
status: "warning",
id: healthId,
name: value.name,
result: "loading",
message,
})
return
}
await effects.setHealth({
name: healthId,
status: "failure",
id: healthId,
name: value.name,
result: "failure",
message: `${result["error-code"][0]}: ${result["error-code"][1]}`,
})
return

View File

@@ -29,6 +29,7 @@ import {
import { HostSystemStartOs } from "../../HostSystemStartOs"
import { JsonPath, unNestPath } from "../../../Models/JsonPath"
import { RpcResult, matchRpcResult } from "../../RpcListener"
import { InputSpec } from "@start9labs/start-sdk/cjs/sdk/lib/config/configTypes"
type Optional<A> = A | undefined | null
function todo(): never {
@@ -259,6 +260,35 @@ export class SystemForEmbassy implements System {
): Promise<void> {
if (previousVersion) await this.migration(effects, previousVersion)
await effects.setMainStatus({ status: "stopped" })
await this.exportActions(effects)
}
async exportActions(effects: HostSystemStartOs) {
const manifest = this.manifest
if (!manifest.actions) return
for (const [actionId, action] of Object.entries(manifest.actions)) {
const hasRunning = !!action["allowed-statuses"].find(
(x) => x === "running",
)
const hasStopped = !!action["allowed-statuses"].find(
(x) => x === "stopped",
)
// prettier-ignore
const allowedStatuses = hasRunning && hasStopped ? "any":
hasRunning ? "onlyRunning" :
"onlyStopped"
await effects.exportAction({
id: actionId,
metadata: {
name: action.name,
description: action.description,
warning: action.warning || null,
input: action["input-spec"] as InputSpec,
disabled: false,
allowedStatuses,
group: null,
},
})
}
}
private async uninit(
effects: HostSystemStartOs,

View File

@@ -15,10 +15,10 @@ export function unNestPath<A extends string>(a: A): UnNestPaths<A> {
function isNestedPath(path: string): path is NestedPaths {
const paths = path.split("/")
if (paths.length !== 4) return false
if (paths[1] === "action" && (paths[3] === "run" || paths[3] === "get"))
if (paths[1] === "actions" && (paths[3] === "run" || paths[3] === "get"))
return true
if (
paths[1] === "dependencyConfig" &&
paths[1] === "dependencies" &&
(paths[3] === "query" || paths[3] === "update")
)
return true

View File

@@ -9,7 +9,7 @@ set -e
if mountpoint tmp/combined; then sudo umount tmp/combined; fi
if mountpoint tmp/lower; then sudo umount tmp/lower; fi
mkdir -p tmp/lower tmp/upper tmp/work tmp/combined
sudo mount alpine.squashfs tmp/lower
sudo mount alpine.${ARCH}.squashfs tmp/lower
sudo mount -t overlay -olowerdir=tmp/lower,upperdir=tmp/upper,workdir=tmp/work overlay tmp/combined
QEMU=
@@ -33,9 +33,9 @@ fi
sudo truncate -s 0 tmp/combined/etc/resolv.conf
sudo chown -R 0:0 tmp/combined
rm -f ../build/lib/container-runtime/rootfs.squashfs
rm -f rootfs.${ARCH}.squashfs
mkdir -p ../build/lib/container-runtime
sudo mksquashfs tmp/combined ../build/lib/container-runtime/rootfs.squashfs
sudo mksquashfs tmp/combined rootfs.${ARCH}.squashfs
sudo umount tmp/combined
sudo umount tmp/lower
sudo rm -rf tmp