@synopackageland/cli 0.48.2 → 0.48.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +8 -0
- package/dist/ctl/ai-tools.d.ts +1 -1
- package/dist/ctl/registry.d.ts +1 -1
- package/dist/standalone/daemon-nofile.d.ts +13 -0
- package/dist/standalone/daemon-nofile.js +96 -0
- package/dist/standalone/daemon.d.ts +2 -0
- package/dist/standalone/daemon.js +8 -0
- package/dist/standalone/inspect-spk.js +35 -7
- package/dist/standalone/lifecycle.js +2 -1
- package/dist/standalone/manifest.js +11 -0
- package/dist/standalone/spk.js +8 -1
- package/package.json +1 -1
- package/schema/synopkgland-api-v2.schema.json +3 -3
- package/skills/reference/lifecycle.md +33 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.48.3
|
|
4
|
+
|
|
5
|
+
- Make v2 job flow timeoutMs optional in commands and operations, matching v1: shared per-request budgets and no total polling deadline; retain explicit bounds and preserve omission through generation
|
|
6
|
+
|
|
7
|
+
- Add opt-in daemon.nofile (1024–1048576) through a fixed DSM-acquired package system unit with LimitNOFILE and package User/Group
|
|
8
|
+
- Preserve SDK-owned deadlines, non-root supervision, legacy omission and upgrade stop/uninstall routing; reject old or mismatched SDK sources
|
|
9
|
+
- Inspect the exact unit, metadata and controller config together; retain SDK 0.49.5 from 0.48.2
|
|
10
|
+
|
|
3
11
|
## 0.48.2
|
|
4
12
|
|
|
5
13
|
- Pin SDK 0.49.5 for CLI-owned controllers and planning so they inherit the shared operation policy
|
package/dist/ctl/ai-tools.d.ts
CHANGED
|
@@ -18,7 +18,7 @@ export declare function listAiTools(client: CtlClient, appName: string, options?
|
|
|
18
18
|
destructiveHint: boolean;
|
|
19
19
|
openWorldHint: boolean;
|
|
20
20
|
};
|
|
21
|
-
ai: "read" | "preview" | "draft" | "human-only"
|
|
21
|
+
ai: "hidden" | "read" | "preview" | "draft" | "human-only";
|
|
22
22
|
flow: import("./descriptor.js").Flow;
|
|
23
23
|
}[];
|
|
24
24
|
}>;
|
package/dist/ctl/registry.d.ts
CHANGED
|
@@ -39,7 +39,7 @@ export declare function registryTools(registry: OperationRegistry): {
|
|
|
39
39
|
destructiveHint: boolean;
|
|
40
40
|
openWorldHint: boolean;
|
|
41
41
|
};
|
|
42
|
-
ai: "read" | "preview" | "draft" | "human-only"
|
|
42
|
+
ai: "hidden" | "read" | "preview" | "draft" | "human-only";
|
|
43
43
|
flow: import("./descriptor.js").Flow;
|
|
44
44
|
}[];
|
|
45
45
|
export declare function registryReference(registry: OperationRegistry): string;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { StandaloneError, StandaloneManifest } from './manifest.js';
|
|
2
|
+
export declare const DAEMON_NOFILE_MIN_SDK = "0.49.5";
|
|
3
|
+
export declare const DAEMON_NOFILE_MIN_DSM = "7.0-40761";
|
|
4
|
+
export declare function daemonNoFileSdkProblem(sdk: string): string | undefined;
|
|
5
|
+
export declare function daemonNoFileIdentityProblem(pkg: string): string | undefined;
|
|
6
|
+
export declare function readNoFile(value: unknown, fail: (e: StandaloneError) => void): number | undefined;
|
|
7
|
+
export declare function daemonSystemUnitName(pkg: string): string;
|
|
8
|
+
export declare function renderDaemonSystemUnit(pkg: string, nofile: number): string;
|
|
9
|
+
/** One fixed dispatch layer covers every native lifecycle composition, including
|
|
10
|
+
* delegated jobs and rootOps. The unit itself calls the SDK directly. */
|
|
11
|
+
export declare function renderNoFileLifecycle(manifest: StandaloneManifest, script: string): string;
|
|
12
|
+
/** Refuse old pins or mismatched local SDK overrides before producing an SPK. */
|
|
13
|
+
export declare function requireDaemonNoFileSource(dir: string, sdk: string, nofile?: number): void;
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import { readFileSync } from 'node:fs';
|
|
2
|
+
import { join } from 'node:path';
|
|
3
|
+
import { StandaloneBuildError } from './spk.js';
|
|
4
|
+
export const DAEMON_NOFILE_MIN_SDK = '0.49.5';
|
|
5
|
+
export const DAEMON_NOFILE_MIN_DSM = '7.0-40761';
|
|
6
|
+
export function daemonNoFileSdkProblem(sdk) {
|
|
7
|
+
const match = /^(\d+)\.(\d+)\.(\d+)$/.exec(sdk);
|
|
8
|
+
if (match) {
|
|
9
|
+
const [major, minor, patch] = match.slice(1).map(Number);
|
|
10
|
+
if (major > 0 || minor > 49 || minor === 49 && patch >= 5)
|
|
11
|
+
return;
|
|
12
|
+
}
|
|
13
|
+
return `daemon.nofile requires SDK ${DAEMON_NOFILE_MIN_SDK} or later; selected SDK ${sdk}`;
|
|
14
|
+
}
|
|
15
|
+
export function daemonNoFileIdentityProblem(pkg) {
|
|
16
|
+
if (!/^[A-Za-z][A-Za-z0-9]{1,63}$/.test(pkg) || pkg.toLowerCase() === 'root')
|
|
17
|
+
return 'daemon.nofile requires a valid non-root package account';
|
|
18
|
+
}
|
|
19
|
+
export function readNoFile(value, fail) {
|
|
20
|
+
if (value === undefined)
|
|
21
|
+
return;
|
|
22
|
+
if (typeof value === 'number' && Number.isSafeInteger(value) && value >= 1024 && value <= 1048576)
|
|
23
|
+
return value;
|
|
24
|
+
fail({ code: 'STANDALONE_DAEMON_NOFILE_INVALID', message: 'daemon.nofile must be an integer from 1024 to 1048576; the daemon always runs as the package account' });
|
|
25
|
+
}
|
|
26
|
+
export function daemonSystemUnitName(pkg) { return `pkg-${pkg}-daemon.service`; }
|
|
27
|
+
export function renderDaemonSystemUnit(pkg, nofile) {
|
|
28
|
+
const problem = daemonNoFileIdentityProblem(pkg);
|
|
29
|
+
if (problem)
|
|
30
|
+
throw new StandaloneBuildError('STANDALONE_DAEMON_NOFILE_INVALID', problem);
|
|
31
|
+
return `[Unit]
|
|
32
|
+
Description=${pkg} daemon
|
|
33
|
+
|
|
34
|
+
[Service]
|
|
35
|
+
Type=oneshot
|
|
36
|
+
RemainAfterExit=yes
|
|
37
|
+
User=${pkg}
|
|
38
|
+
Group=${pkg}
|
|
39
|
+
Slice=${pkg}.slice
|
|
40
|
+
LimitNOFILE=${nofile}
|
|
41
|
+
NoNewPrivileges=yes
|
|
42
|
+
UMask=0077
|
|
43
|
+
ExecStart=/var/packages/${pkg}/target/daemon/control start /var/packages/${pkg}/target /var/packages/${pkg}/var
|
|
44
|
+
ExecStop=/var/packages/${pkg}/target/daemon/control stop /var/packages/${pkg}/target /var/packages/${pkg}/var
|
|
45
|
+
KillMode=control-group
|
|
46
|
+
# The SDK controller owns the validated operation deadlines
|
|
47
|
+
TimeoutStartSec=0
|
|
48
|
+
TimeoutStopSec=0
|
|
49
|
+
`;
|
|
50
|
+
}
|
|
51
|
+
/** One fixed dispatch layer covers every native lifecycle composition, including
|
|
52
|
+
* delegated jobs and rootOps. The unit itself calls the SDK directly. */
|
|
53
|
+
export function renderNoFileLifecycle(manifest, script) {
|
|
54
|
+
if (manifest.daemon?.nofile === undefined)
|
|
55
|
+
return script;
|
|
56
|
+
const pkg = manifest.package, unit = daemonSystemUnitName(pkg);
|
|
57
|
+
const controls = [`"/var/packages/${pkg}/target/daemon/control"`, `"\${SYNOPKG_PKGDEST:-/var/packages/${pkg}/target}/daemon/control"`];
|
|
58
|
+
if (!controls.some(c => script.includes(c)))
|
|
59
|
+
return script;
|
|
60
|
+
for (const control of controls)
|
|
61
|
+
script = script.replaceAll(`exec ${control}`, 'synopkgland_daemon_control').replaceAll(control, 'synopkgland_daemon_control');
|
|
62
|
+
const dispatch = `synopkgland_daemon_control() {
|
|
63
|
+
synopkgland_daemon_action="$1"
|
|
64
|
+
shift
|
|
65
|
+
case "$synopkgland_daemon_action" in
|
|
66
|
+
start|restart) /usr/syno/bin/synosystemctl "$synopkgland_daemon_action" ${unit} ;;
|
|
67
|
+
stop)
|
|
68
|
+
if [ -f /usr/local/lib/systemd/system/${unit} ]; then
|
|
69
|
+
/usr/syno/bin/synosystemctl stop ${unit} || return $?
|
|
70
|
+
fi
|
|
71
|
+
"\${SYNOPKG_PKGDEST:-/var/packages/${pkg}/target}/daemon/control" stop "$@" ;;
|
|
72
|
+
uninstall)
|
|
73
|
+
if [ -f /usr/local/lib/systemd/system/${unit} ]; then
|
|
74
|
+
/usr/syno/bin/synosystemctl stop ${unit} || return $?
|
|
75
|
+
fi
|
|
76
|
+
"\${SYNOPKG_PKGDEST:-/var/packages/${pkg}/target}/daemon/control" uninstall "$@" ;;
|
|
77
|
+
*) "\${SYNOPKG_PKGDEST:-/var/packages/${pkg}/target}/daemon/control" "$synopkgland_daemon_action" "$@" ;;
|
|
78
|
+
esac
|
|
79
|
+
}
|
|
80
|
+
`;
|
|
81
|
+
return script.replace('#!/bin/sh\n', () => `#!/bin/sh\n${dispatch}`);
|
|
82
|
+
}
|
|
83
|
+
/** Refuse old pins or mismatched local SDK overrides before producing an SPK. */
|
|
84
|
+
export function requireDaemonNoFileSource(dir, sdk, nofile) {
|
|
85
|
+
if (nofile === undefined)
|
|
86
|
+
return;
|
|
87
|
+
let main = '', linux = '';
|
|
88
|
+
try {
|
|
89
|
+
main = readFileSync(join(dir, 'daemonctl/main.go'), 'utf8');
|
|
90
|
+
linux = readFileSync(join(dir, 'daemonctl/nofile_linux.go'), 'utf8');
|
|
91
|
+
}
|
|
92
|
+
catch { /* Fail closed below. */ }
|
|
93
|
+
const problem = daemonNoFileSdkProblem(sdk);
|
|
94
|
+
if (problem || !/\bNoFile\s+int\s+`json:"nofile,omitempty"`/.test(main) || !main.includes('validateNoFile(cfg.NoFile)') || !main.includes('applyNoFile(c.NoFile)') || !linux.includes('func applyNoFile('))
|
|
95
|
+
throw new StandaloneBuildError('STANDALONE_DAEMON_NOFILE_SDK_REQUIRED', problem ?? `daemon.nofile requires matching SDK ${DAEMON_NOFILE_MIN_SDK} source with validated non-root NOFILE inheritance; update the SDK pin or development override before building`);
|
|
96
|
+
}
|
|
@@ -5,6 +5,8 @@ import { type DaemonRestart } from "./daemon-restart.js";
|
|
|
5
5
|
import type { CommandRunner } from "./build.js";
|
|
6
6
|
import type { StandaloneError, StandaloneManifest } from "./manifest.js";
|
|
7
7
|
export interface Daemon {
|
|
8
|
+
/** Acquired system-unit file descriptor limit; all processes stay non-root. */
|
|
9
|
+
nofile?: number;
|
|
8
10
|
/** Optional bounded recovery; omission uses the SDK controller default. SDK 0.26.0 or later. */
|
|
9
11
|
restart?: DaemonRestart;
|
|
10
12
|
/** Fixed foreground executable relative to daemon/payload; empty for a backend daemon. */
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { readNoFile, requireDaemonNoFileSource } from "./daemon-nofile.js";
|
|
1
2
|
import { portDefaults } from "./install-ports.js";
|
|
2
3
|
import { operationBudgetSeconds, runtimeBudgetSdkSupported } from "../runtime/runtime-budgets.js";
|
|
3
4
|
import { goChildEnv } from "../runtime/go-env.js";
|
|
@@ -45,6 +46,7 @@ const fields = new Set([
|
|
|
45
46
|
"node",
|
|
46
47
|
"ingress",
|
|
47
48
|
"restart",
|
|
49
|
+
"nofile",
|
|
48
50
|
]);
|
|
49
51
|
const record = (v) => Boolean(v) && typeof v === "object" && !Array.isArray(v);
|
|
50
52
|
/** A fixed argv or env value: only the package's own directories expand. */
|
|
@@ -120,6 +122,9 @@ export function readDaemon(value, root, arches, fail, packageId) {
|
|
|
120
122
|
const timeouts = readLifecycleTimeouts(value.timeouts, fail);
|
|
121
123
|
if (!timeouts)
|
|
122
124
|
return undefined;
|
|
125
|
+
const nofile = readNoFile(value.nofile, fail);
|
|
126
|
+
if (value.nofile !== undefined && nofile === undefined)
|
|
127
|
+
return undefined;
|
|
123
128
|
const restart = readDaemonRestart(value.restart, fail);
|
|
124
129
|
if (value.restart !== undefined && !restart)
|
|
125
130
|
return undefined;
|
|
@@ -146,6 +151,7 @@ export function readDaemon(value, root, arches, fail, packageId) {
|
|
|
146
151
|
...(node ? { node } : {}),
|
|
147
152
|
...(ingress ? { ingress } : {}),
|
|
148
153
|
...(restart ? { restart } : {}),
|
|
154
|
+
...(nofile !== undefined ? { nofile } : {}),
|
|
149
155
|
};
|
|
150
156
|
}
|
|
151
157
|
function readDaemonNode(value, fail) {
|
|
@@ -182,6 +188,7 @@ export function daemonConfig(manifest) {
|
|
|
182
188
|
: runnableDaemon(manifest.package, manifest.daemon);
|
|
183
189
|
return (JSON.stringify({
|
|
184
190
|
package: manifest.package,
|
|
191
|
+
...(manifest.daemon?.nofile !== undefined ? { nofile: manifest.daemon.nofile } : {}),
|
|
185
192
|
...(!manifest.compose && manifest.daemon?.backend ? { backend: true } : { exec }),
|
|
186
193
|
args,
|
|
187
194
|
...(uninstall_args ? { uninstall_args } : {}),
|
|
@@ -231,6 +238,7 @@ export async function buildDaemonControl(manifest, arch, work, run) {
|
|
|
231
238
|
const sdk = daemonSdkVersion(manifest);
|
|
232
239
|
const source = runtimeBudgetSource(sdkSource(sdk).goDir, manifest);
|
|
233
240
|
requireDaemonRestartSource(source, sdk, manifest.daemon?.restart);
|
|
241
|
+
requireDaemonNoFileSource(source, sdk, manifest.daemon?.nofile);
|
|
234
242
|
requireBackendDaemonSource(source, manifest.daemon);
|
|
235
243
|
const result = await run("go", [
|
|
236
244
|
"build",
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { readNoFile, daemonSystemUnitName, renderDaemonSystemUnit, daemonNoFileSdkProblem, daemonNoFileIdentityProblem, DAEMON_NOFILE_MIN_DSM } from "./daemon-nofile.js";
|
|
1
2
|
import { gatewayIngressPathProblem, gatewayIngressOwnershipSupported } from './gateway-ingress.js';
|
|
2
3
|
import { renderGatewayIngressCheck } from './native-gateway.js';
|
|
3
4
|
import { portDefaults, portInstallSteps } from "./install-ports.js";
|
|
@@ -153,7 +154,15 @@ export async function inspectSpk(spkPath, expectedKind) {
|
|
|
153
154
|
}
|
|
154
155
|
}
|
|
155
156
|
const dependencies = inspectPackageDependencies(metadata.dependencies, findings);
|
|
156
|
-
const
|
|
157
|
+
const daemonNoFile = readNoFile(metadata.daemon_nofile, e => findings.push(e.message));
|
|
158
|
+
if (daemonNoFile !== undefined) {
|
|
159
|
+
const problem = daemonNoFileSdkProblem(typeof metadata.daemon_sdk === 'string' ? metadata.daemon_sdk : 'unknown');
|
|
160
|
+
if (problem)
|
|
161
|
+
findings.push(problem);
|
|
162
|
+
}
|
|
163
|
+
if (metadata.daemon_nofile !== undefined && (!paths.has("daemon/control") || metadata.compose !== undefined))
|
|
164
|
+
findings.push("daemon.nofile requires a native daemon controller");
|
|
165
|
+
const daemonRestart = recoverDaemonRestart(metadata.daemon_restart, metadata.daemon_restart === undefined && daemonNoFile !== undefined ? undefined : metadata.daemon_sdk, findings);
|
|
157
166
|
await inspectModuleUi(dir, paths, metadata.ui_module, findings);
|
|
158
167
|
if (metadata.daemon_restart !== undefined && (metadata.compose !== undefined || !paths.has("daemon/control")))
|
|
159
168
|
findings.push("DAEMON_RESTART_INVALID daemon restart requires a native daemon controller, without Compose supervision");
|
|
@@ -228,7 +237,7 @@ export async function inspectSpk(spkPath, expectedKind) {
|
|
|
228
237
|
!isDsmAtLeast(info.os_min_ver, PORTAL_MIN_DSM)) {
|
|
229
238
|
findings.push(`INFO os_min_ver "${info.os_min_ver}" is below the DSM ${PORTAL_MIN_DSM} a portal needs; ${PORTAL_MIN_DSM_REASON}`);
|
|
230
239
|
}
|
|
231
|
-
checkConf(dir, findings, kind, background, sharedFolder, info.package, portal, combined?.compose, nativeGateway, info.os_min_ver, daemonIngress, Boolean(metadata.installPorts));
|
|
240
|
+
checkConf(dir, findings, kind, background, sharedFolder, info.package, portal, combined?.compose, nativeGateway, info.os_min_ver, daemonIngress, Boolean(metadata.installPorts), daemonNoFile);
|
|
232
241
|
checkScripts(dir, findings);
|
|
233
242
|
checkUninstall(dir, findings);
|
|
234
243
|
if (kind === "container")
|
|
@@ -258,7 +267,7 @@ export async function inspectSpk(spkPath, expectedKind) {
|
|
|
258
267
|
if (standalone && portal)
|
|
259
268
|
findings.push(...inspectPortalInfo(info, hasExecutor));
|
|
260
269
|
const daemon = standalone
|
|
261
|
-
? await checkDaemon(dir, info, paths, payload, findings, hasExecutor, background, combined, nativeGateway, uninstallHook?.uninstall, { ingress: daemonIngress, node: daemonNode, restart: daemonRestart, installPorts: Boolean(metadata.installPorts) })
|
|
270
|
+
? await checkDaemon(dir, info, paths, payload, findings, hasExecutor, background, combined, nativeGateway, uninstallHook?.uninstall, { ingress: daemonIngress, node: daemonNode, restart: daemonRestart, nofile: daemonNoFile, installPorts: Boolean(metadata.installPorts) })
|
|
262
271
|
: undefined;
|
|
263
272
|
if (background)
|
|
264
273
|
checkBackground(dir, info, payload, findings, hasExecutor, daemon, kind !== "native-go", metadata.lifecycleTimeouts, nativeGateway, Boolean(metadata.installPorts));
|
|
@@ -990,9 +999,12 @@ async function checkDaemon(dir, info, paths, payload, findings, executor, backgr
|
|
|
990
999
|
"operation_seconds",
|
|
991
1000
|
"uninstall_args",
|
|
992
1001
|
"restart",
|
|
1002
|
+
"nofile",
|
|
993
1003
|
...(combined ? ["network"] : []),
|
|
994
1004
|
].includes(key)))
|
|
995
1005
|
throw new Error("package/config mismatch");
|
|
1006
|
+
if (config.nofile !== extras.nofile)
|
|
1007
|
+
throw new Error("daemon nofile differs from its build declaration");
|
|
996
1008
|
if (!isDeepStrictEqual(config.restart, extras.restart))
|
|
997
1009
|
throw new Error("daemon restart differs from its build declaration");
|
|
998
1010
|
const backend = config.backend === true;
|
|
@@ -1005,6 +1017,7 @@ async function checkDaemon(dir, info, paths, payload, findings, executor, backgr
|
|
|
1005
1017
|
env: config.env,
|
|
1006
1018
|
timeouts: config.timeouts,
|
|
1007
1019
|
restart: config.restart,
|
|
1020
|
+
nofile: config.nofile,
|
|
1008
1021
|
targets: { x86_64: "payload" },
|
|
1009
1022
|
}, dir, ["x86_64"], () => { }, info.package);
|
|
1010
1023
|
if (!daemon)
|
|
@@ -1334,7 +1347,7 @@ async function recoverDaemonIngress(dir, value, info, paths, findings) {
|
|
|
1334
1347
|
return undefined;
|
|
1335
1348
|
}
|
|
1336
1349
|
}
|
|
1337
|
-
function checkConf(dir, findings, kind, background, sharedFolder, pkg, portal, compose, nativeGateway, osMinVer, daemonIngress, installPorts = false) {
|
|
1350
|
+
function checkConf(dir, findings, kind, background, sharedFolder, pkg, portal, compose, nativeGateway, osMinVer, daemonIngress, installPorts = false, nofile) {
|
|
1338
1351
|
const confDir = join(dir, "conf");
|
|
1339
1352
|
const entries = existsSync(confDir) ? readdirSync(confDir) : [];
|
|
1340
1353
|
const nativeResource = kind !== "container"
|
|
@@ -1359,10 +1372,26 @@ function checkConf(dir, findings, kind, background, sharedFolder, pkg, portal, c
|
|
|
1359
1372
|
if (name !== "privilege" &&
|
|
1360
1373
|
!(kind === "container" && name === "resource") &&
|
|
1361
1374
|
!(nativeResource !== undefined && name === "resource") &&
|
|
1362
|
-
!(background && name === "systemd")) {
|
|
1375
|
+
!((background || nofile !== undefined) && name === "systemd")) {
|
|
1363
1376
|
findings.push(`conf/${name} registers an extra resource with DSM; a Standalone Package does not produce it`);
|
|
1364
1377
|
}
|
|
1365
1378
|
}
|
|
1379
|
+
if (nofile !== undefined && pkg) {
|
|
1380
|
+
if (!osMinVer || !isDsmAtLeast(osMinVer, DAEMON_NOFILE_MIN_DSM))
|
|
1381
|
+
findings.push(`daemon.nofile requires DSM ${DAEMON_NOFILE_MIN_DSM} or later`);
|
|
1382
|
+
const unit = daemonSystemUnitName(pkg);
|
|
1383
|
+
const identityProblem = daemonNoFileIdentityProblem(pkg);
|
|
1384
|
+
if (identityProblem)
|
|
1385
|
+
findings.push(identityProblem);
|
|
1386
|
+
else if (readOptional(join(confDir, "systemd", unit)) !== renderDaemonSystemUnit(pkg, nofile))
|
|
1387
|
+
findings.push("daemon NOFILE system unit must match the fixed package account, limit and lifecycle");
|
|
1388
|
+
}
|
|
1389
|
+
if (background || nofile !== undefined) {
|
|
1390
|
+
const expected = [...(background && pkg ? [backgroundUnitName(pkg)] : []), ...(nofile !== undefined && pkg ? [daemonSystemUnitName(pkg)] : [])].sort();
|
|
1391
|
+
const actual = existsSync(join(confDir, "systemd")) ? readdirSync(join(confDir, "systemd")).sort() : [];
|
|
1392
|
+
if (!isDeepStrictEqual(actual, expected))
|
|
1393
|
+
findings.push("conf/systemd contains missing or extra package units");
|
|
1394
|
+
}
|
|
1366
1395
|
if (kind === "container") {
|
|
1367
1396
|
try {
|
|
1368
1397
|
const resource = JSON.parse(readFileSync(join(confDir, "resource"), "utf8"));
|
|
@@ -1423,8 +1452,7 @@ function checkBackground(dir, info, payload, findings, executor, daemon, bridge
|
|
|
1423
1452
|
? readdirSync(join(dir, BACKGROUND_UNIT_DIR))
|
|
1424
1453
|
: [];
|
|
1425
1454
|
const unit = backgroundUnitName(pkg);
|
|
1426
|
-
if (units.
|
|
1427
|
-
units[0] !== unit ||
|
|
1455
|
+
if (!isDeepStrictEqual(units.sort(), [unit, ...(daemon?.nofile !== undefined ? [daemonSystemUnitName(pkg)] : [])].sort()) ||
|
|
1428
1456
|
read(`${BACKGROUND_UNIT_DIR}/${unit}`) !==
|
|
1429
1457
|
renderBackgroundUnit(pkg, bridge ? BRIDGE_WORKER_ARGS : [], daemon?.timeouts.stop ?? lifecycleTimeouts?.stop ?? 30)) {
|
|
1430
1458
|
findings.push(`${BACKGROUND_UNIT_DIR} must contain only the fixed ${unit} (runs as the package account, no User=, no root)`);
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { renderNoFileLifecycle } from "./daemon-nofile.js";
|
|
1
2
|
import { renderGatewayIngressCheck } from './native-gateway.js';
|
|
2
3
|
import { renderSettingsHook } from './install-settings.js';
|
|
3
4
|
import { renderComposeRetainedData } from "../build-spk/compose-retained-data.js";
|
|
@@ -15,7 +16,7 @@ import { composeAppScript } from "./app-scripts.js";
|
|
|
15
16
|
const UNINSTALL_ONLY = '[ "${SYNOPKG_PKG_STATUS:-}" = UPGRADE ] || synopkgland_uninstall_hook\n';
|
|
16
17
|
/** Package-account lifecycle hooks for CGI, daemon and background packages. */
|
|
17
18
|
export function renderStandaloneScript(name, manifest) {
|
|
18
|
-
const script = renderStandaloneScriptInternal(name, manifest);
|
|
19
|
+
const script = renderNoFileLifecycle(manifest, renderStandaloneScriptInternal(name, manifest));
|
|
19
20
|
const prefix = renderStandaloneScriptPrefix(name, manifest);
|
|
20
21
|
const sdk = prefix ? script.replace('#!/bin/sh\n', () => '#!/bin/sh\n' + prefix) : script;
|
|
21
22
|
return manifest.appScripts?.some((app) => app === name)
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { daemonNoFileSdkProblem, daemonNoFileIdentityProblem, DAEMON_NOFILE_MIN_DSM } from './daemon-nofile.js';
|
|
1
2
|
import { readRegistry, registryFile } from '../ctl/registry.js';
|
|
2
3
|
import { gatewayIngressPathProblem, gatewayIngressOwnershipSupported } from './gateway-ingress.js';
|
|
3
4
|
import { nativeGatewaySdk } from "./native-gateway.js";
|
|
@@ -347,6 +348,16 @@ function readManifest(raw, c) {
|
|
|
347
348
|
if (problem)
|
|
348
349
|
c.fail("STANDALONE_DAEMON_INGRESS_MIN_DSM", problem);
|
|
349
350
|
}
|
|
351
|
+
if (daemon?.nofile !== undefined && backend) {
|
|
352
|
+
if (osMinVer && !isDsmAtLeast(osMinVer, DAEMON_NOFILE_MIN_DSM))
|
|
353
|
+
c.fail('STANDALONE_DAEMON_NOFILE_DSM_REQUIRED', `daemon.nofile requires DSM ${DAEMON_NOFILE_MIN_DSM} or later; the target is never raised automatically`);
|
|
354
|
+
const problem = daemonNoFileSdkProblem(daemonSdkVersion({ backend, identityGateway }));
|
|
355
|
+
if (problem)
|
|
356
|
+
c.fail('STANDALONE_DAEMON_NOFILE_SDK_REQUIRED', problem);
|
|
357
|
+
const identityProblem = daemonNoFileIdentityProblem(packageId ?? '');
|
|
358
|
+
if (identityProblem)
|
|
359
|
+
c.fail('STANDALONE_DAEMON_NOFILE_INVALID', identityProblem);
|
|
360
|
+
}
|
|
350
361
|
if (daemon?.restart && backend) {
|
|
351
362
|
const problem = daemonRestartSdkProblem(daemonSdkVersion({ backend, identityGateway }));
|
|
352
363
|
if (problem)
|
package/dist/standalone/spk.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { daemonSystemUnitName, renderDaemonSystemUnit } from "./daemon-nofile.js";
|
|
1
2
|
import { gatewayIngressOwnershipSupported } from './gateway-ingress.js';
|
|
2
3
|
import { portDefaults, portInstallSteps, writePortPayload } from "./install-ports.js";
|
|
3
4
|
import { packageDependencies, dependencyInfo } from "./package-dependencies.js";
|
|
@@ -272,7 +273,9 @@ export async function assembleStandaloneSpk(options) {
|
|
|
272
273
|
...(nativeGatewaySupported(manifest) ? { native_gateway: { sdk: manifest.identityGateway.sdk, listen: manifest.identityGateway.listen, ...(manifest.identityGateway.ingress ? { ingress: manifest.identityGateway.ingress } : {}) } } : {}),
|
|
273
274
|
...(manifest.daemon?.ingress ? { daemon_ingress: manifest.daemon.ingress } : {}),
|
|
274
275
|
...(manifest.daemon?.node ? { daemon_node: manifest.daemon.node } : {}),
|
|
275
|
-
...(manifest.daemon?.
|
|
276
|
+
...(manifest.daemon?.nofile !== undefined ? { daemon_nofile: manifest.daemon.nofile } : {}),
|
|
277
|
+
...(manifest.daemon?.restart ? { daemon_restart: manifest.daemon.restart } : {}),
|
|
278
|
+
...(manifest.daemon?.restart || manifest.daemon?.nofile !== undefined ? { daemon_sdk: daemonSdkVersion(manifest) } : {}),
|
|
276
279
|
launch: resolvedSdkLaunch(manifest),
|
|
277
280
|
capabilities: Object.keys(manifest.capabilities).sort(),
|
|
278
281
|
...(manifest.compose
|
|
@@ -299,6 +302,10 @@ export async function assembleStandaloneSpk(options) {
|
|
|
299
302
|
const resource = renderStandaloneResource(manifest, portal);
|
|
300
303
|
if (resource)
|
|
301
304
|
writeFile(join(staging, "conf", "resource"), resource);
|
|
305
|
+
if (manifest.daemon?.nofile !== undefined) {
|
|
306
|
+
mkdirSync(join(staging, "conf/systemd"), { recursive: true });
|
|
307
|
+
writeFile(join(staging, "conf/systemd", daemonSystemUnitName(manifest.package)), renderDaemonSystemUnit(manifest.package, manifest.daemon.nofile));
|
|
308
|
+
}
|
|
302
309
|
if (manifest.capabilities.jobs) {
|
|
303
310
|
mkdirSync(join(staging, BACKGROUND_UNIT_DIR), { recursive: true });
|
|
304
311
|
writeFile(join(staging, BACKGROUND_UNIT_DIR, backgroundUnitName(manifest.package)), renderBackgroundUnit(manifest.package, isBridgeBackend(manifest.backend) ? BRIDGE_WORKER_ARGS : [], manifest.daemon?.timeouts.stop ?? manifest.lifecycleTimeouts?.stop ?? 30));
|
package/package.json
CHANGED
|
@@ -430,7 +430,8 @@
|
|
|
430
430
|
"timeoutMs": {
|
|
431
431
|
"type": "integer",
|
|
432
432
|
"minimum": 10,
|
|
433
|
-
"maximum": 3600000
|
|
433
|
+
"maximum": 3600000,
|
|
434
|
+
"description": "Optional per-request allowance; omission uses the shared operation budget, with polling until completion or cancellation and no total elapsed limit"
|
|
434
435
|
}
|
|
435
436
|
},
|
|
436
437
|
"required": [
|
|
@@ -442,8 +443,7 @@
|
|
|
442
443
|
"state",
|
|
443
444
|
"done",
|
|
444
445
|
"failed",
|
|
445
|
-
"intervalMs"
|
|
446
|
-
"timeoutMs"
|
|
446
|
+
"intervalMs"
|
|
447
447
|
]
|
|
448
448
|
}
|
|
449
449
|
]
|
|
@@ -133,3 +133,36 @@ continue. The executor helper's JSON state distinguishes `accepted`,
|
|
|
133
133
|
request and does not prove cleanup finished. Unconfirmed cleanup retains protected
|
|
134
134
|
state for a later retry. DSM's outer install/uninstall deadline is not established
|
|
135
135
|
by these settings.
|
|
136
|
+
|
|
137
|
+
|
|
138
|
+
## Daemon file descriptor budget
|
|
139
|
+
|
|
140
|
+
Native daemon Apps may opt in with `daemon.nofile: 32768`. The value must be an
|
|
141
|
+
integer from 1024 to 1048576; omission keeps the legacy controller path. This
|
|
142
|
+
requires DSM 7.0-40761 or later and SDK 0.49.5 or later, including an explicit Go App SDK pin or gateway
|
|
143
|
+
pin. CLI 0.48.3 retains the SDK 0.49.5 default introduced in 0.48.2. Check and
|
|
144
|
+
build reject older pins; build also verifies matching controller sources.
|
|
145
|
+
|
|
146
|
+
The CLI generates only `conf/systemd/pkg-<package>-daemon.service`. DSM acquires
|
|
147
|
+
this fixed system unit directly; it needs no `systemd-user-unit` resource
|
|
148
|
+
(that worker is for `pkguser-*` user units). See the
|
|
149
|
+
[official acquired-unit contract](https://help.synology.com/developer-guide/resource_acquisition/systemd_user_unit.html). `LimitNOFILE` sets its inherited soft/hard budget;
|
|
150
|
+
`User` and `Group` stay the package account, with `NoNewPrivileges=yes` and
|
|
151
|
+
`KillMode=control-group`. A root package identity is refused. Apps cannot supply
|
|
152
|
+
arbitrary units, identities, commands or root lifecycle work through this field.
|
|
153
|
+
The SDK daemon controller verifies the inherited hard limit and raises only the
|
|
154
|
+
soft limit before launching its non-root worker; insufficient inheritance fails
|
|
155
|
+
with `DAEMON_NOFILE_INSUFFICIENT`.
|
|
156
|
+
|
|
157
|
+
Generated start/restart uses the acquired unit; status stays on the SDK
|
|
158
|
+
controller. Stop also calls the idempotent SDK stop to cover an upgrade from a
|
|
159
|
+
legacy controller, including when a new unit file is already present. Uninstall
|
|
160
|
+
stops the unit then invokes the existing SDK uninstall path. The unit leaves
|
|
161
|
+
outer systemd start/stop timeouts disabled so the SDK's existing validated
|
|
162
|
+
`daemon.timeouts` remain the single work deadline. Inspect rejects a missing,
|
|
163
|
+
extra or changed unit and mismatched metadata/controller configuration.
|
|
164
|
+
|
|
165
|
+
After publishing and deploying an opted-in package, read the actual worker UID
|
|
166
|
+
and soft/hard limits after upgrade/restart. Generated files and local SPK tests
|
|
167
|
+
alone do not establish DSM acquisition, inherited worker limits or full lifecycle
|
|
168
|
+
acceptance on a NAS.
|