@rcpooley/concord 0.1.0
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/LICENSE +21 -0
- package/README.md +318 -0
- package/bin/concord.service +69 -0
- package/dist/age.d.ts +20 -0
- package/dist/age.d.ts.map +1 -0
- package/dist/age.js +58 -0
- package/dist/age.js.map +1 -0
- package/dist/cli/main.d.ts +3 -0
- package/dist/cli/main.d.ts.map +1 -0
- package/dist/cli/main.js +301 -0
- package/dist/cli/main.js.map +1 -0
- package/dist/daemon.d.ts +4 -0
- package/dist/daemon.d.ts.map +1 -0
- package/dist/daemon.js +394 -0
- package/dist/daemon.js.map +1 -0
- package/dist/eval-config.d.ts +2 -0
- package/dist/eval-config.d.ts.map +1 -0
- package/dist/eval-config.js +45 -0
- package/dist/eval-config.js.map +1 -0
- package/dist/exec.d.ts +168 -0
- package/dist/exec.d.ts.map +1 -0
- package/dist/exec.js +313 -0
- package/dist/exec.js.map +1 -0
- package/dist/git.d.ts +59 -0
- package/dist/git.d.ts.map +1 -0
- package/dist/git.js +265 -0
- package/dist/git.js.map +1 -0
- package/dist/hook.d.ts +37 -0
- package/dist/hook.d.ts.map +1 -0
- package/dist/hook.js +89 -0
- package/dist/hook.js.map +1 -0
- package/dist/index.d.ts +18 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +15 -0
- package/dist/index.js.map +1 -0
- package/dist/init.d.ts +76 -0
- package/dist/init.d.ts.map +1 -0
- package/dist/init.js +236 -0
- package/dist/init.js.map +1 -0
- package/dist/loader.d.ts +35 -0
- package/dist/loader.d.ts.map +1 -0
- package/dist/loader.js +230 -0
- package/dist/loader.js.map +1 -0
- package/dist/module.d.ts +116 -0
- package/dist/module.d.ts.map +1 -0
- package/dist/module.js +100 -0
- package/dist/module.js.map +1 -0
- package/dist/modules/apt/index.d.ts +45 -0
- package/dist/modules/apt/index.d.ts.map +1 -0
- package/dist/modules/apt/index.js +249 -0
- package/dist/modules/apt/index.js.map +1 -0
- package/dist/modules/apt/schema.d.ts +63 -0
- package/dist/modules/apt/schema.d.ts.map +1 -0
- package/dist/modules/apt/schema.js +75 -0
- package/dist/modules/apt/schema.js.map +1 -0
- package/dist/modules/checkout/index.d.ts +88 -0
- package/dist/modules/checkout/index.d.ts.map +1 -0
- package/dist/modules/checkout/index.js +382 -0
- package/dist/modules/checkout/index.js.map +1 -0
- package/dist/modules/checkout/schema.d.ts +52 -0
- package/dist/modules/checkout/schema.d.ts.map +1 -0
- package/dist/modules/checkout/schema.js +132 -0
- package/dist/modules/checkout/schema.js.map +1 -0
- package/dist/modules/cloudflare/api.d.ts +64 -0
- package/dist/modules/cloudflare/api.d.ts.map +1 -0
- package/dist/modules/cloudflare/api.js +98 -0
- package/dist/modules/cloudflare/api.js.map +1 -0
- package/dist/modules/cloudflare/index.d.ts +74 -0
- package/dist/modules/cloudflare/index.d.ts.map +1 -0
- package/dist/modules/cloudflare/index.js +374 -0
- package/dist/modules/cloudflare/index.js.map +1 -0
- package/dist/modules/cloudflare/schema.d.ts +62 -0
- package/dist/modules/cloudflare/schema.d.ts.map +1 -0
- package/dist/modules/cloudflare/schema.js +85 -0
- package/dist/modules/cloudflare/schema.js.map +1 -0
- package/dist/modules/docker/index.d.ts +83 -0
- package/dist/modules/docker/index.d.ts.map +1 -0
- package/dist/modules/docker/index.js +470 -0
- package/dist/modules/docker/index.js.map +1 -0
- package/dist/modules/docker/registry.d.ts +35 -0
- package/dist/modules/docker/registry.d.ts.map +1 -0
- package/dist/modules/docker/registry.js +95 -0
- package/dist/modules/docker/registry.js.map +1 -0
- package/dist/modules/docker/render.d.ts +45 -0
- package/dist/modules/docker/render.d.ts.map +1 -0
- package/dist/modules/docker/render.js +162 -0
- package/dist/modules/docker/render.js.map +1 -0
- package/dist/modules/docker/schema.d.ts +231 -0
- package/dist/modules/docker/schema.d.ts.map +1 -0
- package/dist/modules/docker/schema.js +335 -0
- package/dist/modules/docker/schema.js.map +1 -0
- package/dist/modules/docker/sweeper.d.ts +64 -0
- package/dist/modules/docker/sweeper.d.ts.map +1 -0
- package/dist/modules/docker/sweeper.js +94 -0
- package/dist/modules/docker/sweeper.js.map +1 -0
- package/dist/modules/file/index.d.ts +79 -0
- package/dist/modules/file/index.d.ts.map +1 -0
- package/dist/modules/file/index.js +305 -0
- package/dist/modules/file/index.js.map +1 -0
- package/dist/modules/file/schema.d.ts +45 -0
- package/dist/modules/file/schema.d.ts.map +1 -0
- package/dist/modules/file/schema.js +114 -0
- package/dist/modules/file/schema.js.map +1 -0
- package/dist/modules/index.d.ts +20 -0
- package/dist/modules/index.d.ts.map +1 -0
- package/dist/modules/index.js +11 -0
- package/dist/modules/index.js.map +1 -0
- package/dist/modules/porkbun/api.d.ts +36 -0
- package/dist/modules/porkbun/api.d.ts.map +1 -0
- package/dist/modules/porkbun/api.js +62 -0
- package/dist/modules/porkbun/api.js.map +1 -0
- package/dist/modules/porkbun/index.d.ts +50 -0
- package/dist/modules/porkbun/index.d.ts.map +1 -0
- package/dist/modules/porkbun/index.js +236 -0
- package/dist/modules/porkbun/index.js.map +1 -0
- package/dist/modules/porkbun/schema.d.ts +38 -0
- package/dist/modules/porkbun/schema.d.ts.map +1 -0
- package/dist/modules/porkbun/schema.js +39 -0
- package/dist/modules/porkbun/schema.js.map +1 -0
- package/dist/modules/script/index.d.ts +43 -0
- package/dist/modules/script/index.d.ts.map +1 -0
- package/dist/modules/script/index.js +116 -0
- package/dist/modules/script/index.js.map +1 -0
- package/dist/modules/script/schema.d.ts +25 -0
- package/dist/modules/script/schema.d.ts.map +1 -0
- package/dist/modules/script/schema.js +63 -0
- package/dist/modules/script/schema.js.map +1 -0
- package/dist/modules/systemd/index.d.ts +93 -0
- package/dist/modules/systemd/index.d.ts.map +1 -0
- package/dist/modules/systemd/index.js +394 -0
- package/dist/modules/systemd/index.js.map +1 -0
- package/dist/modules/systemd/render.d.ts +41 -0
- package/dist/modules/systemd/render.d.ts.map +1 -0
- package/dist/modules/systemd/render.js +252 -0
- package/dist/modules/systemd/render.js.map +1 -0
- package/dist/modules/systemd/schema.d.ts +293 -0
- package/dist/modules/systemd/schema.d.ts.map +1 -0
- package/dist/modules/systemd/schema.js +302 -0
- package/dist/modules/systemd/schema.js.map +1 -0
- package/dist/modules/systemd/sweeper.d.ts +31 -0
- package/dist/modules/systemd/sweeper.d.ts.map +1 -0
- package/dist/modules/systemd/sweeper.js +77 -0
- package/dist/modules/systemd/sweeper.js.map +1 -0
- package/dist/plans.d.ts +132 -0
- package/dist/plans.d.ts.map +1 -0
- package/dist/plans.js +315 -0
- package/dist/plans.js.map +1 -0
- package/dist/records.d.ts +37 -0
- package/dist/records.d.ts.map +1 -0
- package/dist/records.js +100 -0
- package/dist/records.js.map +1 -0
- package/dist/registry.d.ts +38 -0
- package/dist/registry.d.ts.map +1 -0
- package/dist/registry.js +31 -0
- package/dist/registry.js.map +1 -0
- package/dist/runner.d.ts +48 -0
- package/dist/runner.d.ts.map +1 -0
- package/dist/runner.js +150 -0
- package/dist/runner.js.map +1 -0
- package/dist/scheduler.d.ts +36 -0
- package/dist/scheduler.d.ts.map +1 -0
- package/dist/scheduler.js +77 -0
- package/dist/scheduler.js.map +1 -0
- package/dist/schema.d.ts +762 -0
- package/dist/schema.d.ts.map +1 -0
- package/dist/schema.js +185 -0
- package/dist/schema.js.map +1 -0
- package/dist/secret.d.ts +24 -0
- package/dist/secret.d.ts.map +1 -0
- package/dist/secret.js +3 -0
- package/dist/secret.js.map +1 -0
- package/dist/ui.d.ts +62 -0
- package/dist/ui.d.ts.map +1 -0
- package/dist/ui.js +288 -0
- package/dist/ui.js.map +1 -0
- package/package.json +57 -0
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { SecretSchema } from '../../secret.js';
|
|
3
|
+
export const ScriptSchema = z
|
|
4
|
+
.object({
|
|
5
|
+
name: z.string().regex(/^[a-z0-9][a-z0-9-]*$/, 'must be kebab-case, starting alphanumeric'),
|
|
6
|
+
/**
|
|
7
|
+
* The idempotency guard. **Exit 0 means converged; non-zero means run.**
|
|
8
|
+
*
|
|
9
|
+
* REQUIRED, with no way to opt out — this is what lets an arbitrary command
|
|
10
|
+
* be a module at all. `read()` cannot enumerate "commands that have been
|
|
11
|
+
* run", so the read is delegated here instead of abandoned, which is what
|
|
12
|
+
* keeps plan-before-apply, honest convergence, and drift detection working.
|
|
13
|
+
* Without it a 15-minute timer would re-run every script forever and
|
|
14
|
+
* `converged — no changes` would be a lie.
|
|
15
|
+
*
|
|
16
|
+
* Keep it CHEAP — it runs on every reconcile, including plans.
|
|
17
|
+
*/
|
|
18
|
+
unless: z.string().min(1),
|
|
19
|
+
/** Run when the guard fails. Executed with `bash -c`, never through a shell string. */
|
|
20
|
+
run: z.string().min(1),
|
|
21
|
+
/** Run both the guard and the command as root. */
|
|
22
|
+
sudo: z.boolean().optional(),
|
|
23
|
+
/**
|
|
24
|
+
* Secrets the script reads as SHELL VARIABLES, e.g. `"$PORKBUN_API_KEY"`.
|
|
25
|
+
*
|
|
26
|
+
* Each is DECRYPTED on the primary and assigned, single-quoted, ahead of
|
|
27
|
+
* both `unless` and `run`. A variable's value is never re-parsed by bash, so
|
|
28
|
+
* a quote, `$(…)` or newline in a secret is just data. They are NOT
|
|
29
|
+
* exported: a script whose child process needs one says `export NAME`.
|
|
30
|
+
*
|
|
31
|
+
* Needed at all because `secrets['x']` is age ciphertext at author time, so a
|
|
32
|
+
* template literal would embed the ciphertext. Anything non-secret should
|
|
33
|
+
* just use a TypeScript template literal — the config is real code.
|
|
34
|
+
*/
|
|
35
|
+
secrets: z
|
|
36
|
+
.record(z.string().regex(/^[A-Za-z_][A-Za-z0-9_]*$/, 'must be a valid shell variable name'), SecretSchema)
|
|
37
|
+
.optional(),
|
|
38
|
+
/** Seconds before the command is killed. Guards get a fixed short timeout. */
|
|
39
|
+
timeout: z.number().int().positive().max(3600).optional(),
|
|
40
|
+
})
|
|
41
|
+
.strict();
|
|
42
|
+
export const ScriptConfigSchema = z
|
|
43
|
+
.object({
|
|
44
|
+
type: z.literal('script'),
|
|
45
|
+
id: z.string().regex(/^[a-z0-9][a-z0-9-]*$/, 'must be kebab-case, starting alphanumeric'),
|
|
46
|
+
/**
|
|
47
|
+
* Run in declared order. Deliberately the escape hatch: reach for it when
|
|
48
|
+
* something is needed once or twice, and promote it to a real typed module
|
|
49
|
+
* once the same shape appears repeatedly. Building the abstraction from one
|
|
50
|
+
* example usually builds the wrong abstraction.
|
|
51
|
+
*/
|
|
52
|
+
/**
|
|
53
|
+
* Which host this runs on — a key of the config's `hosts` registry.
|
|
54
|
+
*
|
|
55
|
+
* REQUIRED, with no default. A silently-defaulting host is a way to run
|
|
56
|
+
* something on the wrong machine, and "wherever Concord happens to be
|
|
57
|
+
* running" is not a property a config should depend on.
|
|
58
|
+
*/
|
|
59
|
+
host: z.string().min(1),
|
|
60
|
+
scripts: z.array(ScriptSchema).optional(),
|
|
61
|
+
})
|
|
62
|
+
.strict();
|
|
63
|
+
//# sourceMappingURL=schema.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema.js","sourceRoot":"","sources":["../../../src/modules/script/schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AACvB,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAA;AAE9C,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC;KAC1B,MAAM,CAAC;IACN,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,KAAK,CAAC,sBAAsB,EAAE,2CAA2C,CAAC;IAE3F;;;;;;;;;;;OAWG;IACH,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;IAEzB,uFAAuF;IACvF,GAAG,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;IAEtB,kDAAkD;IAClD,IAAI,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,QAAQ,EAAE;IAE5B;;;;;;;;;;;OAWG;IACH,OAAO,EAAE,CAAC;SACP,MAAM,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,KAAK,CAAC,0BAA0B,EAAE,qCAAqC,CAAC,EAAE,YAAY,CAAC;SACzG,QAAQ,EAAE;IAEb,8EAA8E;IAC9E,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,QAAQ,EAAE,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,QAAQ,EAAE;CAC1D,CAAC;KACD,MAAM,EAAE,CAAA;AAEX,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC;KAChC,MAAM,CAAC;IACN,IAAI,EAAE,CAAC,CAAC,OAAO,CAAC,QAAQ,CAAC;IACzB,EAAE,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,KAAK,CAAC,sBAAsB,EAAE,2CAA2C,CAAC;IAEzF;;;;;OAKG;IAEH;;;;;;OAMG;IACH,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;IACvB,OAAO,EAAE,CAAC,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC,QAAQ,EAAE;CAC1C,CAAC;KACD,MAAM,EAAE,CAAA"}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { Module, type BaseOp } from '../../module.js';
|
|
2
|
+
import type { SystemdConfig } from './schema.js';
|
|
3
|
+
export type { SystemdConfig } from './schema.js';
|
|
4
|
+
export { renderUnit, parseUnit, unitsEquivalent } from './render.js';
|
|
5
|
+
export declare const UNIT_DIR = "/etc/systemd/system";
|
|
6
|
+
export declare const unitPath: (name: string) => string;
|
|
7
|
+
/**
|
|
8
|
+
* Concord's own units are hand-placed bootstrap and stay that way.
|
|
9
|
+
*
|
|
10
|
+
* Restarting the unit the reconciler is currently running under kills the run
|
|
11
|
+
* mid-apply, so this is refused outright rather than handled. The static names
|
|
12
|
+
* catch an interactive `concord plan`; the cgroup check catches a rename.
|
|
13
|
+
*/
|
|
14
|
+
export declare const SELF_UNITS: Set<string>;
|
|
15
|
+
/**
|
|
16
|
+
* What a generated .timer or .path actually starts.
|
|
17
|
+
*
|
|
18
|
+
* `Unit=` when given; otherwise systemd's implicit default — the same basename
|
|
19
|
+
* with `.service`. The implicit form matters: a unit named `concord.path` with
|
|
20
|
+
* no `Unit=` targets `concord.service` without ever naming it.
|
|
21
|
+
*/
|
|
22
|
+
export declare function triggerTarget(u: {
|
|
23
|
+
name: string;
|
|
24
|
+
unit?: {
|
|
25
|
+
timer?: {
|
|
26
|
+
unit?: string;
|
|
27
|
+
};
|
|
28
|
+
path?: {
|
|
29
|
+
unit?: string;
|
|
30
|
+
};
|
|
31
|
+
};
|
|
32
|
+
}): string | null;
|
|
33
|
+
export declare function selfUnit(): string | null;
|
|
34
|
+
export interface UnitState {
|
|
35
|
+
name: string;
|
|
36
|
+
/** undefined = not declared, so not compared. */
|
|
37
|
+
enabled?: boolean;
|
|
38
|
+
active?: boolean;
|
|
39
|
+
/** Rendered content of the file Concord owns. Generated units only. */
|
|
40
|
+
unitFile?: string;
|
|
41
|
+
/** A watched file is newer than the unit's start — its config is not loaded. */
|
|
42
|
+
stale?: string;
|
|
43
|
+
}
|
|
44
|
+
export interface MaskState {
|
|
45
|
+
name: string;
|
|
46
|
+
masked: boolean;
|
|
47
|
+
active: boolean;
|
|
48
|
+
}
|
|
49
|
+
export interface SystemdState {
|
|
50
|
+
units: UnitState[];
|
|
51
|
+
masked: MaskState[];
|
|
52
|
+
}
|
|
53
|
+
export interface SystemdOp extends BaseOp {
|
|
54
|
+
entity: 'unit-file' | 'enablement' | 'activation' | 'mask' | 'removal';
|
|
55
|
+
name: string;
|
|
56
|
+
/** For unit-file ops. */
|
|
57
|
+
content?: string;
|
|
58
|
+
action?: 'enable' | 'disable' | 'start' | 'stop' | 'restart' | 'reload' | 'mask' | 'unmask';
|
|
59
|
+
healthTimeout?: number;
|
|
60
|
+
}
|
|
61
|
+
type Props = Record<string, string>;
|
|
62
|
+
/** `systemctl show` a batch of units. Blank-line separated, one block each. */
|
|
63
|
+
export declare function parseShow(stdout: string): Map<string, Props>;
|
|
64
|
+
export declare class SystemdModule extends Module<SystemdState, SystemdOp> {
|
|
65
|
+
private readonly config;
|
|
66
|
+
readonly kind = "systemd";
|
|
67
|
+
constructor(config: SystemdConfig);
|
|
68
|
+
/** The unit files this instance WRITES — the sweep keep-set contribution.
|
|
69
|
+
* Referenced-but-not-written units (enabled/active only) are not Concord's
|
|
70
|
+
* files and must never appear here. */
|
|
71
|
+
owned(): string[];
|
|
72
|
+
private get units();
|
|
73
|
+
private show;
|
|
74
|
+
desired(): Promise<SystemdState>;
|
|
75
|
+
read(): Promise<SystemdState>;
|
|
76
|
+
/**
|
|
77
|
+
* Has a watched file changed since the unit last started?
|
|
78
|
+
*
|
|
79
|
+
* Stateless by design: the unit's own `ActiveEnterTimestamp` is the baseline,
|
|
80
|
+
* so this is correct on the very first run on a bare host — where a hash
|
|
81
|
+
* database would have no baseline at all.
|
|
82
|
+
*/
|
|
83
|
+
private staleness;
|
|
84
|
+
diff(actual: SystemdState, desired: SystemdState): SystemdOp[];
|
|
85
|
+
apply(ops: SystemdOp[]): Promise<void>;
|
|
86
|
+
/**
|
|
87
|
+
* A unit that fails to come back must fail the RUN, not retry silently every
|
|
88
|
+
* 15 minutes. Without this the plan would simply be non-empty forever, which
|
|
89
|
+
* would be indistinguishable from ordinary drift.
|
|
90
|
+
*/
|
|
91
|
+
private healthCheck;
|
|
92
|
+
}
|
|
93
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/modules/systemd/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,MAAM,EAAE,KAAK,MAAM,EAAE,MAAM,iBAAiB,CAAA;AAErD,OAAO,KAAK,EAAE,aAAa,EAAc,MAAM,aAAa,CAA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E,MAAM,CAAA;IACZ,yBAAyB;IACzB,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,MAAM,CAAC,EAAE,QAAQ,GAAG,SAAS,GAAG,OAAO,GAAG,MAAM,GAAG,SAAS,GAAG,QAAQ,GAAG,MAAM,GAAG,QAAQ,CAAA;IAC3F,aAAa,CAAC,EAAE,MAAM,CAAA;CACvB;AAED,KAAK,KAAK,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;AAEnC,+EAA+E;AAC/E,wBAAgB,SAAS,CAAC,MAAM,EAAE,MAAM,GAAG,GAAG,CAAC,MAAM,EAAE,KAAK,CAAC,CAW5D;AAcD,qBAAa,aAAc,SAAQ,MAAM,CAAC,YAAY,EAAE,SAAS,CAAC;IAGpD,OAAO,CAAC,QAAQ,CAAC,MAAM;IAFnC,SAAkB,IAAI,aAAY;gBAEL,MAAM,EAAE,aAAa;IAIlD;;4CAEwC;IAC/B,KAAK,IAAI,MAAM,EAAE;IAI1B,OAAO,KAAK,KAAK,GAEhB;IAED,OAAO,CAAC,IAAI;IAWN,OAAO,IAAI,OAAO,CAAC,YAAY,CAAC;IAgEhC,IAAI,IAAI,OAAO,CAAC,YAAY,CAAC;IAgCnC;;;;;;OAMG;IACH,OAAO,CAAC,SAAS;IAiBjB,IAAI,CAAC,MAAM,EAAE,YAAY,EAAE,OAAO,EAAE,YAAY,GAAG,SAAS,EAAE;IAyHxD,KAAK,CAAC,GAAG,EAAE,SAAS,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAmC5C;;;;OAIG;YACW,WAAW;CAwC1B"}
|
|
@@ -0,0 +1,394 @@
|
|
|
1
|
+
import { sleep } from '../../exec.js';
|
|
2
|
+
import { readFileSync } from 'node:fs';
|
|
3
|
+
import { Module } from '../../module.js';
|
|
4
|
+
import { renderUnit, unitsEquivalent } from './render.js';
|
|
5
|
+
export { renderUnit, parseUnit, unitsEquivalent } from './render.js';
|
|
6
|
+
export const UNIT_DIR = '/etc/systemd/system';
|
|
7
|
+
export const unitPath = (name) => `${UNIT_DIR}/${name}`;
|
|
8
|
+
const SHOW_PROPS = [
|
|
9
|
+
'Id',
|
|
10
|
+
'LoadState',
|
|
11
|
+
'UnitFileState',
|
|
12
|
+
'ActiveState',
|
|
13
|
+
'SubState',
|
|
14
|
+
'Result',
|
|
15
|
+
'ActiveEnterTimestamp',
|
|
16
|
+
'NeedDaemonReload',
|
|
17
|
+
'CanReload',
|
|
18
|
+
'Type',
|
|
19
|
+
'RemainAfterExit',
|
|
20
|
+
];
|
|
21
|
+
/**
|
|
22
|
+
* Concord's own units are hand-placed bootstrap and stay that way.
|
|
23
|
+
*
|
|
24
|
+
* Restarting the unit the reconciler is currently running under kills the run
|
|
25
|
+
* mid-apply, so this is refused outright rather than handled. The static names
|
|
26
|
+
* catch an interactive `concord plan`; the cgroup check catches a rename.
|
|
27
|
+
*/
|
|
28
|
+
export const SELF_UNITS = new Set(['concord.service', 'concord.timer']);
|
|
29
|
+
/**
|
|
30
|
+
* What a generated .timer or .path actually starts.
|
|
31
|
+
*
|
|
32
|
+
* `Unit=` when given; otherwise systemd's implicit default — the same basename
|
|
33
|
+
* with `.service`. The implicit form matters: a unit named `concord.path` with
|
|
34
|
+
* no `Unit=` targets `concord.service` without ever naming it.
|
|
35
|
+
*/
|
|
36
|
+
export function triggerTarget(u) {
|
|
37
|
+
const section = u.unit?.timer ?? u.unit?.path;
|
|
38
|
+
if (!section)
|
|
39
|
+
return null;
|
|
40
|
+
if (section.unit)
|
|
41
|
+
return section.unit;
|
|
42
|
+
return u.name.replace(/\.(timer|path)$/, '') + '.service';
|
|
43
|
+
}
|
|
44
|
+
export function selfUnit() {
|
|
45
|
+
try {
|
|
46
|
+
const m = /\/([^/]+\.(?:service|timer))$/.exec(readFileSync('/proc/self/cgroup', 'utf8').trim());
|
|
47
|
+
return m ? m[1] : null;
|
|
48
|
+
}
|
|
49
|
+
catch {
|
|
50
|
+
return null;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
/** `systemctl show` a batch of units. Blank-line separated, one block each. */
|
|
54
|
+
export function parseShow(stdout) {
|
|
55
|
+
const out = new Map();
|
|
56
|
+
for (const block of stdout.split(/\n\s*\n/)) {
|
|
57
|
+
const props = {};
|
|
58
|
+
for (const line of block.split('\n')) {
|
|
59
|
+
const eq = line.indexOf('=');
|
|
60
|
+
if (eq > 0)
|
|
61
|
+
props[line.slice(0, eq)] = line.slice(eq + 1);
|
|
62
|
+
}
|
|
63
|
+
if (props.Id)
|
|
64
|
+
out.set(props.Id, props);
|
|
65
|
+
}
|
|
66
|
+
return out;
|
|
67
|
+
}
|
|
68
|
+
const isEnabled = (p) => p?.UnitFileState === 'enabled' || p?.UnitFileState === 'enabled-runtime';
|
|
69
|
+
/** `@1783592024`, or empty for a unit that has never started. */
|
|
70
|
+
function activeEnter(p) {
|
|
71
|
+
const raw = p?.ActiveEnterTimestamp ?? '';
|
|
72
|
+
const m = /^@(\d+)$/.exec(raw.trim());
|
|
73
|
+
return m ? Number(m[1]) : null;
|
|
74
|
+
}
|
|
75
|
+
// --------------------------------------------------------------- module ----
|
|
76
|
+
export class SystemdModule extends Module {
|
|
77
|
+
config;
|
|
78
|
+
kind = 'systemd';
|
|
79
|
+
constructor(config) {
|
|
80
|
+
super(config.id, config.host);
|
|
81
|
+
this.config = config;
|
|
82
|
+
}
|
|
83
|
+
/** The unit files this instance WRITES — the sweep keep-set contribution.
|
|
84
|
+
* Referenced-but-not-written units (enabled/active only) are not Concord's
|
|
85
|
+
* files and must never appear here. */
|
|
86
|
+
owned() {
|
|
87
|
+
return this.units.filter((u) => u.unit).map((u) => u.name);
|
|
88
|
+
}
|
|
89
|
+
get units() {
|
|
90
|
+
return this.config.units ?? [];
|
|
91
|
+
}
|
|
92
|
+
show(names) {
|
|
93
|
+
if (!names.length)
|
|
94
|
+
return new Map();
|
|
95
|
+
const r = this.exec.run('systemctl', [
|
|
96
|
+
'show',
|
|
97
|
+
...names,
|
|
98
|
+
...SHOW_PROPS.flatMap((p) => ['-p', p]),
|
|
99
|
+
'--timestamp=unix',
|
|
100
|
+
]);
|
|
101
|
+
return parseShow(r.stdout);
|
|
102
|
+
}
|
|
103
|
+
async desired() {
|
|
104
|
+
const seen = new Set();
|
|
105
|
+
const self = selfUnit();
|
|
106
|
+
const units = this.units.map((u) => {
|
|
107
|
+
if (seen.has(u.name)) {
|
|
108
|
+
throw new Error(`${this.kind}:${this.id}: "${u.name}" declared twice`);
|
|
109
|
+
}
|
|
110
|
+
seen.add(u.name);
|
|
111
|
+
if (SELF_UNITS.has(u.name) || u.name === self) {
|
|
112
|
+
throw new Error(`${this.kind}:${this.id}: refusing to manage "${u.name}" — this is the unit ` +
|
|
113
|
+
`Concord runs under. Restarting it would kill the run mid-apply, so its unit ` +
|
|
114
|
+
`file stays hand-placed bootstrap.`);
|
|
115
|
+
}
|
|
116
|
+
// A unit does not have to BE a self-unit to control one. A .timer or
|
|
117
|
+
// .path carrying `Unit=concord.service` is a second trigger for Concord,
|
|
118
|
+
// declared by config — which is the thing this guard exists to prevent,
|
|
119
|
+
// and it walked straight past the name check once already.
|
|
120
|
+
const target = triggerTarget(u);
|
|
121
|
+
if (target && (SELF_UNITS.has(target) || target === self)) {
|
|
122
|
+
throw new Error(`${this.kind}:${this.id}: refusing to manage "${u.name}" — it triggers "${target}", ` +
|
|
123
|
+
`which is the unit Concord runs under. Whether and when Concord runs is bootstrap, ` +
|
|
124
|
+
`not config: a config mistake here could stop the fleet reconciling and take away ` +
|
|
125
|
+
`the mechanism that would fix it.`);
|
|
126
|
+
}
|
|
127
|
+
// Same reasoning for Conflicts=: starting such a unit stops Concord.
|
|
128
|
+
for (const c of u.unit?.conflicts ?? []) {
|
|
129
|
+
if (SELF_UNITS.has(c) || c === self) {
|
|
130
|
+
throw new Error(`${this.kind}:${this.id}: refusing to manage "${u.name}" — it declares ` +
|
|
131
|
+
`Conflicts=${c}, which would stop the unit Concord runs under.`);
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
return {
|
|
135
|
+
name: u.name,
|
|
136
|
+
enabled: u.enabled,
|
|
137
|
+
active: u.active,
|
|
138
|
+
...(u.unit ? { unitFile: renderUnit(u.unit, `${this.kind}:${this.id}`) } : {}),
|
|
139
|
+
// "not stale" is the whole desired state here; read() computes the real
|
|
140
|
+
// answer by comparing mtimes to the unit's start.
|
|
141
|
+
...(u.watches ? { stale: '' } : {}),
|
|
142
|
+
};
|
|
143
|
+
});
|
|
144
|
+
for (const m of this.config.masked ?? []) {
|
|
145
|
+
if (seen.has(m)) {
|
|
146
|
+
throw new Error(`${this.kind}:${this.id}: "${m}" declared both as a unit and masked — pick one.`);
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
return {
|
|
150
|
+
units,
|
|
151
|
+
masked: (this.config.masked ?? []).map((name) => ({ name, masked: true, active: false })),
|
|
152
|
+
};
|
|
153
|
+
}
|
|
154
|
+
async read() {
|
|
155
|
+
const names = [...this.units.map((u) => u.name), ...(this.config.masked ?? [])];
|
|
156
|
+
const props = this.show(names);
|
|
157
|
+
const units = this.units.map((u) => {
|
|
158
|
+
const p = props.get(u.name);
|
|
159
|
+
const state = {
|
|
160
|
+
name: u.name,
|
|
161
|
+
...(u.enabled !== undefined ? { enabled: isEnabled(p) } : {}),
|
|
162
|
+
...(u.active !== undefined ? { active: p?.ActiveState === 'active' } : {}),
|
|
163
|
+
// Compare against the path Concord OWNS, not FragmentPath — before the
|
|
164
|
+
// first write, FragmentPath still points at the vendor unit.
|
|
165
|
+
...(u.unit ? { unitFile: this.exec.sudoReadFileMaybe(unitPath(u.name)) } : {}),
|
|
166
|
+
};
|
|
167
|
+
if (u.watches)
|
|
168
|
+
state.stale = this.staleness(u, activeEnter(p));
|
|
169
|
+
return state;
|
|
170
|
+
});
|
|
171
|
+
return {
|
|
172
|
+
units,
|
|
173
|
+
masked: (this.config.masked ?? []).map((name) => {
|
|
174
|
+
const p = props.get(name);
|
|
175
|
+
return {
|
|
176
|
+
name,
|
|
177
|
+
masked: p?.UnitFileState === 'masked',
|
|
178
|
+
active: p?.ActiveState === 'active',
|
|
179
|
+
};
|
|
180
|
+
}),
|
|
181
|
+
};
|
|
182
|
+
}
|
|
183
|
+
/**
|
|
184
|
+
* Has a watched file changed since the unit last started?
|
|
185
|
+
*
|
|
186
|
+
* Stateless by design: the unit's own `ActiveEnterTimestamp` is the baseline,
|
|
187
|
+
* so this is correct on the very first run on a bare host — where a hash
|
|
188
|
+
* database would have no baseline at all.
|
|
189
|
+
*/
|
|
190
|
+
staleness(u, startedAt) {
|
|
191
|
+
// Never started: it is about to be started anyway, which loads everything.
|
|
192
|
+
if (startedAt === null)
|
|
193
|
+
return '';
|
|
194
|
+
for (const w of u.watches ?? []) {
|
|
195
|
+
for (const path of w.paths) {
|
|
196
|
+
const st = this.exec.statMaybe(path);
|
|
197
|
+
if (!st) {
|
|
198
|
+
this.log(` ⚠ ${u.name} watches ${path}, which does not exist`);
|
|
199
|
+
continue;
|
|
200
|
+
}
|
|
201
|
+
if (st.mtime > startedAt)
|
|
202
|
+
return `${w.onChange}:${path}`;
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
return '';
|
|
206
|
+
}
|
|
207
|
+
diff(actual, desired) {
|
|
208
|
+
const fileOps = [];
|
|
209
|
+
const enableOps = [];
|
|
210
|
+
const activeOps = [];
|
|
211
|
+
const maskOps = [];
|
|
212
|
+
const byName = new Map(actual.units.map((u) => [u.name, u]));
|
|
213
|
+
for (const [i, want] of desired.units.entries()) {
|
|
214
|
+
const cfg = this.units[i];
|
|
215
|
+
const have = byName.get(want.name);
|
|
216
|
+
let unitFileChanged = false;
|
|
217
|
+
if (want.unitFile !== undefined) {
|
|
218
|
+
const current = have?.unitFile ?? '';
|
|
219
|
+
// Directive-set comparison, so an equivalent hand-written unit is
|
|
220
|
+
// adopted without a rewrite — and therefore without a restart.
|
|
221
|
+
if (!current) {
|
|
222
|
+
fileOps.push({
|
|
223
|
+
kind: 'create',
|
|
224
|
+
entity: 'unit-file',
|
|
225
|
+
id: `unit/${want.name}`,
|
|
226
|
+
summary: `write unit ${want.name}`,
|
|
227
|
+
name: want.name,
|
|
228
|
+
content: want.unitFile,
|
|
229
|
+
});
|
|
230
|
+
unitFileChanged = true;
|
|
231
|
+
}
|
|
232
|
+
else if (!unitsEquivalent(current, want.unitFile)) {
|
|
233
|
+
fileOps.push({
|
|
234
|
+
kind: 'update',
|
|
235
|
+
entity: 'unit-file',
|
|
236
|
+
id: `unit/${want.name}`,
|
|
237
|
+
summary: `update unit ${want.name}`,
|
|
238
|
+
name: want.name,
|
|
239
|
+
content: want.unitFile,
|
|
240
|
+
});
|
|
241
|
+
unitFileChanged = true;
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
if (want.enabled !== undefined && have?.enabled !== want.enabled) {
|
|
245
|
+
enableOps.push({
|
|
246
|
+
kind: 'update',
|
|
247
|
+
entity: 'enablement',
|
|
248
|
+
id: `enabled/${want.name}`,
|
|
249
|
+
summary: `${want.enabled ? 'enable' : 'disable'} ${want.name}`,
|
|
250
|
+
name: want.name,
|
|
251
|
+
action: want.enabled ? 'enable' : 'disable',
|
|
252
|
+
});
|
|
253
|
+
}
|
|
254
|
+
if (want.active !== undefined && have?.active !== want.active) {
|
|
255
|
+
activeOps.push({
|
|
256
|
+
kind: 'update',
|
|
257
|
+
entity: 'activation',
|
|
258
|
+
id: `active/${want.name}`,
|
|
259
|
+
summary: `${want.active ? 'start' : 'stop'} ${want.name}`,
|
|
260
|
+
name: want.name,
|
|
261
|
+
action: want.active ? 'start' : 'stop',
|
|
262
|
+
healthTimeout: cfg.healthTimeout,
|
|
263
|
+
});
|
|
264
|
+
}
|
|
265
|
+
else if (unitFileChanged && have?.active) {
|
|
266
|
+
// daemon-reload alone re-reads the FILE; the running process keeps the
|
|
267
|
+
// definition it was started with. Without this, an ExecStart change
|
|
268
|
+
// would apply silently at the next reboot and nowhere sooner.
|
|
269
|
+
activeOps.push({
|
|
270
|
+
kind: 'update',
|
|
271
|
+
entity: 'activation',
|
|
272
|
+
id: `active/${want.name}`,
|
|
273
|
+
summary: `restart ${want.name} (unit definition changed)`,
|
|
274
|
+
name: want.name,
|
|
275
|
+
action: 'restart',
|
|
276
|
+
healthTimeout: cfg.healthTimeout,
|
|
277
|
+
});
|
|
278
|
+
}
|
|
279
|
+
else if (have?.stale) {
|
|
280
|
+
// Only when the unit is already in the right activation state — a unit
|
|
281
|
+
// being started fresh loads its config anyway.
|
|
282
|
+
const [action, path] = have.stale.split(/:(.*)/s);
|
|
283
|
+
activeOps.push({
|
|
284
|
+
kind: 'update',
|
|
285
|
+
entity: 'activation',
|
|
286
|
+
id: `active/${want.name}`,
|
|
287
|
+
summary: `${action} ${want.name} (${path} changed)`,
|
|
288
|
+
name: want.name,
|
|
289
|
+
action,
|
|
290
|
+
healthTimeout: cfg.healthTimeout,
|
|
291
|
+
});
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
for (const want of desired.masked) {
|
|
295
|
+
const have = actual.masked.find((m) => m.name === want.name);
|
|
296
|
+
if (have?.active) {
|
|
297
|
+
maskOps.push({
|
|
298
|
+
kind: 'update',
|
|
299
|
+
entity: 'activation',
|
|
300
|
+
id: `active/${want.name}`,
|
|
301
|
+
summary: `stop ${want.name}`,
|
|
302
|
+
name: want.name,
|
|
303
|
+
action: 'stop',
|
|
304
|
+
});
|
|
305
|
+
}
|
|
306
|
+
if (!have?.masked) {
|
|
307
|
+
maskOps.push({
|
|
308
|
+
kind: 'update',
|
|
309
|
+
entity: 'mask',
|
|
310
|
+
id: `mask/${want.name}`,
|
|
311
|
+
summary: `mask ${want.name}`,
|
|
312
|
+
name: want.name,
|
|
313
|
+
action: 'mask',
|
|
314
|
+
});
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
// Files, then enablement, then activation — a unit cannot be enabled before
|
|
318
|
+
// its file exists, nor started before it is reloaded. (Withdrawal is not
|
|
319
|
+
// this module's job any more: the sweeper removes any tagged unit no
|
|
320
|
+
// module declares, at the tail of the run.)
|
|
321
|
+
return [...fileOps, ...enableOps, ...activeOps, ...maskOps];
|
|
322
|
+
}
|
|
323
|
+
async apply(ops) {
|
|
324
|
+
const files = ops.filter((o) => o.entity === 'unit-file');
|
|
325
|
+
for (const op of files) {
|
|
326
|
+
this.exec.writeFileAsRoot(unitPath(op.name), op.content, '0644');
|
|
327
|
+
this.log(` ✓ ${op.kind}: ${op.summary}`);
|
|
328
|
+
}
|
|
329
|
+
// One reload for the whole batch, before anything is enabled or started.
|
|
330
|
+
if (files.length) {
|
|
331
|
+
this.exec.sudo(['systemctl', 'daemon-reload']);
|
|
332
|
+
this.log(' ✓ systemctl daemon-reload');
|
|
333
|
+
}
|
|
334
|
+
for (const op of ops.filter((o) => o.entity === 'enablement')) {
|
|
335
|
+
this.exec.sudo(['systemctl', op.action, op.name]);
|
|
336
|
+
this.log(` ✓ ${op.summary}`);
|
|
337
|
+
}
|
|
338
|
+
const started = [];
|
|
339
|
+
for (const op of ops.filter((o) => o.entity === 'activation')) {
|
|
340
|
+
this.exec.sudo(['systemctl', op.action, op.name]);
|
|
341
|
+
this.log(` ✓ ${op.summary}`);
|
|
342
|
+
if (op.action !== 'stop')
|
|
343
|
+
started.push(op);
|
|
344
|
+
}
|
|
345
|
+
// Masking last: `systemctl mask` does not stop a running unit, so the stop
|
|
346
|
+
// op above has to land first.
|
|
347
|
+
for (const op of ops.filter((o) => o.entity === 'mask')) {
|
|
348
|
+
this.exec.sudo(['systemctl', op.action, op.name]);
|
|
349
|
+
this.log(` ✓ ${op.summary}`);
|
|
350
|
+
}
|
|
351
|
+
for (const op of started)
|
|
352
|
+
await this.healthCheck(op.name, op.healthTimeout ?? 30);
|
|
353
|
+
}
|
|
354
|
+
/**
|
|
355
|
+
* A unit that fails to come back must fail the RUN, not retry silently every
|
|
356
|
+
* 15 minutes. Without this the plan would simply be non-empty forever, which
|
|
357
|
+
* would be indistinguishable from ordinary drift.
|
|
358
|
+
*/
|
|
359
|
+
async healthCheck(name, timeoutSec) {
|
|
360
|
+
const deadline = Date.now() + timeoutSec * 1000;
|
|
361
|
+
let props = this.show([name]).get(name);
|
|
362
|
+
while (props?.ActiveState === 'activating' && Date.now() < deadline) {
|
|
363
|
+
await sleep(500);
|
|
364
|
+
props = this.show([name]).get(name);
|
|
365
|
+
}
|
|
366
|
+
const fail = (why) => {
|
|
367
|
+
const log = this.exec.run('sudo', ['-n', 'journalctl', '-u', name, '-n', '20', '--no-pager']);
|
|
368
|
+
throw new Error(`${this.kind}:${this.id}: ${name} ${why}\n` +
|
|
369
|
+
` ActiveState=${props?.ActiveState} SubState=${props?.SubState} Result=${props?.Result}\n` +
|
|
370
|
+
log.stdout.trim());
|
|
371
|
+
};
|
|
372
|
+
if (props?.ActiveState === 'activating')
|
|
373
|
+
fail(`did not settle within ${timeoutSec}s`);
|
|
374
|
+
// Type-agnostic: a successful oneshot ends `inactive` with Result=success,
|
|
375
|
+
// so failure is read from Result rather than from ActiveState alone.
|
|
376
|
+
if (props?.ActiveState === 'failed' || (props?.Result && props.Result !== 'success')) {
|
|
377
|
+
fail('failed to start');
|
|
378
|
+
}
|
|
379
|
+
// "active" can be a lie for a few seconds behind Restart=always — the unit
|
|
380
|
+
// is crash-looping and simply happened to be up when we looked. If its start
|
|
381
|
+
// timestamp moves, it restarted underneath us.
|
|
382
|
+
const before = activeEnter(props);
|
|
383
|
+
await sleep(3000);
|
|
384
|
+
props = this.show([name]).get(name);
|
|
385
|
+
if (props?.ActiveState === 'failed' || (props?.Result && props.Result !== 'success')) {
|
|
386
|
+
fail('failed shortly after starting');
|
|
387
|
+
}
|
|
388
|
+
if (before !== null && activeEnter(props) !== before) {
|
|
389
|
+
fail('is restarting in a loop (its start timestamp moved while we watched)');
|
|
390
|
+
}
|
|
391
|
+
this.log(` ✓ health: ${name} is ${props?.ActiveState}/${props?.SubState}`);
|
|
392
|
+
}
|
|
393
|
+
}
|
|
394
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@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AC,CAAA;QACrF,2EAA2E;QAC3E,qEAAqE;QACrE,IAAI,KAAK,EAAE,WAAW,KAAK,QAAQ,IAAI,CAAC,KAAK,EAAE,MAAM,IAAI,KAAK,CAAC,MAAM,KAAK,SAAS,CAAC,EAAE,CAAC;YACrF,IAAI,CAAC,iBAAiB,CAAC,CAAA;QACzB,CAAC;QAED,2EAA2E;QAC3E,6EAA6E;QAC7E,+CAA+C;QAC/C,MAAM,MAAM,GAAG,WAAW,CAAC,KAAK,CAAC,CAAA;QACjC,MAAM,KAAK,CAAC,IAAI,CAAC,CAAA;QACjB,KAAK,GAAG,IAAI,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,CAAA;QACnC,IAAI,KAAK,EAAE,WAAW,KAAK,QAAQ,IAAI,CAAC,KAAK,EAAE,MAAM,IAAI,KAAK,CAAC,MAAM,KAAK,SAAS,CAAC,EAAE,CAAC;YACrF,IAAI,CAAC,+BAA+B,CAAC,CAAA;QACvC,CAAC;QACD,IAAI,MAAM,KAAK,IAAI,IAAI,WAAW,CAAC,KAAK,CAAC,KAAK,MAAM,EAAE,CAAC;YACrD,IAAI,CAAC,sEAAsE,CAAC,CAAA;QAC9E,CAAC;QAED,IAAI,CAAC,GAAG,CAAC,eAAe,IAAI,OAAO,KAAK,EAAE,WAAW,IAAI,KAAK,EAAE,QAAQ,EAAE,CAAC,CAAA;IAC7E,CAAC;CACF"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import type { UnitFileConfig } from './schema.js';
|
|
2
|
+
/**
|
|
3
|
+
* Rendering and comparison of unit files.
|
|
4
|
+
*
|
|
5
|
+
* Units are GENERATED from typed fields rather than installed from checked-in
|
|
6
|
+
* files, and compared as DIRECTIVE SETS rather than as text — so adopting an
|
|
7
|
+
* existing hand-written unit whose directives already match is a zero-restart
|
|
8
|
+
* operation.
|
|
9
|
+
*/
|
|
10
|
+
export declare const MANAGED_HEADER = "# Managed by Concord. Local edits are reverted on the next run.";
|
|
11
|
+
/**
|
|
12
|
+
* The ownership tag, present in `[Unit]` of every file Concord writes.
|
|
13
|
+
*
|
|
14
|
+
* ⚠️ WIRE FORMAT — never rename. The sweep identifies Concord-written units by
|
|
15
|
+
* this exact directive, so renaming it orphans every unit written before the
|
|
16
|
+
* rename. systemd documents that `X-`-prefixed directives are ignored
|
|
17
|
+
* (verified against .service, .timer, .target and template units).
|
|
18
|
+
*
|
|
19
|
+
* Deliberately a CONSTANT, not the module id: a directive participates in
|
|
20
|
+
* `unitsEquivalent`, so an id here would restart every unit a module writes
|
|
21
|
+
* when the module is renamed in config — and at sweep time the id would be
|
|
22
|
+
* stale by definition, since the sweep only ever reads the tag on units whose
|
|
23
|
+
* module is gone. The module id lives in the comment header instead, where
|
|
24
|
+
* humans look and the comparison doesn't.
|
|
25
|
+
*/
|
|
26
|
+
export declare const OWNER_TAG: [string, string];
|
|
27
|
+
type Line = [directive: string, value: string];
|
|
28
|
+
/** @param owner The writing module's scope (`systemd:<id>`), for the header. */
|
|
29
|
+
export declare function renderUnit(u: UnitFileConfig, owner?: string): string;
|
|
30
|
+
export type ParsedUnit = Map<string, Line[]>;
|
|
31
|
+
export declare function parseUnit(text: string): ParsedUnit;
|
|
32
|
+
/**
|
|
33
|
+
* Do two unit files mean the same thing?
|
|
34
|
+
*
|
|
35
|
+
* Ignores comments, blank lines, section order and the ordering of set-valued
|
|
36
|
+
* directives — so a hand-written unit that already says the right thing is
|
|
37
|
+
* adopted without a restart.
|
|
38
|
+
*/
|
|
39
|
+
export declare function unitsEquivalent(a: string, b: string): boolean;
|
|
40
|
+
export {};
|
|
41
|
+
//# sourceMappingURL=render.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"render.d.ts","sourceRoot":"","sources":["../../../src/modules/systemd/render.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AAEjD;;;;;;;GAOG;AAEH,eAAO,MAAM,cAAc,oEAAoE,CAAA;AAE/F;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,SAAS,EAAE,CAAC,MAAM,EAAE,MAAM,CAAsB,CAAA;AAmB7D,KAAK,IAAI,GAAG,CAAC,SAAS,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,CAAC,CAAA;AAmC9C,gFAAgF;AAChF,wBAAgB,UAAU,CAAC,CAAC,EAAE,cAAc,EAAE,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,CAmGpE;AASD,MAAM,MAAM,UAAU,GAAG,GAAG,CAAC,MAAM,EAAE,IAAI,EAAE,CAAC,CAAA;AAE5C,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,UAAU,CA2BlD;AAkCD;;;;;;GAMG;AACH,wBAAgB,eAAe,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,OAAO,CAW7D"}
|