@futurelastic/muster 0.5.0-rc.3 → 0.5.0-rc.31
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/README.md +4 -0
- package/bin/muster.js +41 -19
- package/package.json +5 -5
package/README.md
CHANGED
|
@@ -206,6 +206,10 @@ a platform package whose version differs from its own. Release candidates
|
|
|
206
206
|
publish under the `next` dist-tag (`npx @futurelastic/muster@next`); `latest`
|
|
207
207
|
only ever moves to a final release.
|
|
208
208
|
|
|
209
|
+
Windows is built and tested by every release but not published to npm yet, and
|
|
210
|
+
has no interactive-terminal driver; see
|
|
211
|
+
[`docs/install.md`](docs/install.md#windows).
|
|
212
|
+
|
|
209
213
|
Configure it with the `FLEET_*` environment the [Quickstart](#quickstart) shows
|
|
210
214
|
and start it with `muster serve`. A service that survives a reboot is
|
|
211
215
|
[`docs/install.md`](docs/install.md). Build from source only to hack on it.
|
package/bin/muster.js
CHANGED
|
@@ -11,7 +11,19 @@ const fs = require('node:fs');
|
|
|
11
11
|
const path = require('node:path');
|
|
12
12
|
const { spawn } = require('node:child_process');
|
|
13
13
|
|
|
14
|
-
const
|
|
14
|
+
const SCOPE = '@futurelastic/muster-';
|
|
15
|
+
|
|
16
|
+
// The platforms this launcher supports are the ones its own package.json lists
|
|
17
|
+
// as optionalDependencies — assembled from the release, so there is no second
|
|
18
|
+
// list here to drift from it. An unpublished platform (windows, today) is
|
|
19
|
+
// absent from that list in a normal release and present when assembled with
|
|
20
|
+
// --all, and the launcher follows without a code change.
|
|
21
|
+
function supportedFrom(optionalDependencies) {
|
|
22
|
+
return Object.keys(optionalDependencies || {})
|
|
23
|
+
.filter((n) => n.startsWith(SCOPE))
|
|
24
|
+
.map((n) => n.slice(SCOPE.length))
|
|
25
|
+
.sort();
|
|
26
|
+
}
|
|
15
27
|
|
|
16
28
|
function fail(message) {
|
|
17
29
|
process.stderr.write(`muster: ${message}\n`);
|
|
@@ -20,12 +32,14 @@ function fail(message) {
|
|
|
20
32
|
|
|
21
33
|
// resolveBinary returns the absolute path of the platform package's binary, or
|
|
22
34
|
// throws an Error whose message says what to do. Exported through `require.main`
|
|
23
|
-
// so the test can drive it without spawning anything.
|
|
24
|
-
|
|
35
|
+
// so the test can drive it without spawning anything. `optionalDependencies` is
|
|
36
|
+
// this package's own, which is what defines "supported".
|
|
37
|
+
function resolveBinary(platform, arch, resolve, ownVersion, optionalDependencies) {
|
|
25
38
|
const key = `${platform}-${arch}`;
|
|
26
|
-
|
|
39
|
+
const supported = supportedFrom(optionalDependencies);
|
|
40
|
+
if (!supported.includes(key)) {
|
|
27
41
|
throw new Error(
|
|
28
|
-
`no prebuilt binary for ${key} (supported: ${
|
|
42
|
+
`no prebuilt binary for ${key} (supported: ${supported.join(', ') || 'none'}). ` +
|
|
29
43
|
'Build from source: https://github.com/futurelastic/muster#install'
|
|
30
44
|
);
|
|
31
45
|
}
|
|
@@ -50,34 +64,42 @@ function resolveBinary(platform, arch, resolve, ownVersion) {
|
|
|
50
64
|
'Reinstall so both come from the same release.'
|
|
51
65
|
);
|
|
52
66
|
}
|
|
53
|
-
|
|
67
|
+
// Npm names follow process.platform, so windows is win32 and its binary is
|
|
68
|
+
// muster.exe.
|
|
69
|
+
return path.join(path.dirname(manifest), 'bin', platform === 'win32' ? 'muster.exe' : 'muster');
|
|
54
70
|
}
|
|
55
71
|
|
|
56
72
|
function run() {
|
|
57
|
-
const
|
|
73
|
+
const manifest = require('../package.json');
|
|
58
74
|
let bin;
|
|
59
75
|
try {
|
|
60
|
-
bin = resolveBinary(process.platform, process.arch, require.resolve,
|
|
76
|
+
bin = resolveBinary(process.platform, process.arch, require.resolve, manifest.version, manifest.optionalDependencies);
|
|
61
77
|
} catch (err) {
|
|
62
78
|
fail(err.message);
|
|
63
79
|
}
|
|
64
80
|
// A tarball extracted without the executable bit (some mirrors do this)
|
|
65
|
-
// would otherwise fail with an opaque EACCES.
|
|
66
|
-
|
|
67
|
-
fs.accessSync(bin, fs.constants.X_OK);
|
|
68
|
-
} catch {
|
|
81
|
+
// would otherwise fail with an opaque EACCES. Windows has no such bit.
|
|
82
|
+
if (process.platform !== 'win32') {
|
|
69
83
|
try {
|
|
70
|
-
fs.
|
|
71
|
-
} catch
|
|
72
|
-
|
|
84
|
+
fs.accessSync(bin, fs.constants.X_OK);
|
|
85
|
+
} catch {
|
|
86
|
+
try {
|
|
87
|
+
fs.chmodSync(bin, 0o755);
|
|
88
|
+
} catch (err) {
|
|
89
|
+
fail(`${bin} is not executable and could not be made so: ${err.message}`);
|
|
90
|
+
}
|
|
73
91
|
}
|
|
74
92
|
}
|
|
75
93
|
|
|
76
94
|
const child = spawn(bin, process.argv.slice(2), { stdio: 'inherit' });
|
|
77
95
|
// The service handles these itself (a graceful stop); pass them on rather
|
|
78
|
-
// than dying first and orphaning it.
|
|
79
|
-
|
|
80
|
-
|
|
96
|
+
// than dying first and orphaning it. Not on Windows: there a signal sent to a
|
|
97
|
+
// child is a hard kill, which is the opposite of passing it on — and a console
|
|
98
|
+
// Ctrl+C already reaches the child itself, as it shares the console.
|
|
99
|
+
if (process.platform !== 'win32') {
|
|
100
|
+
for (const sig of ['SIGINT', 'SIGTERM', 'SIGHUP']) {
|
|
101
|
+
process.on(sig, () => child.kill(sig));
|
|
102
|
+
}
|
|
81
103
|
}
|
|
82
104
|
child.on('error', (err) => fail(`could not start ${bin}: ${err.message}`));
|
|
83
105
|
child.on('exit', (code, signal) => {
|
|
@@ -93,5 +115,5 @@ function run() {
|
|
|
93
115
|
if (require.main === module) {
|
|
94
116
|
run();
|
|
95
117
|
} else {
|
|
96
|
-
module.exports = { resolveBinary,
|
|
118
|
+
module.exports = { resolveBinary, supportedFrom };
|
|
97
119
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@futurelastic/muster",
|
|
3
|
-
"version": "0.5.0-rc.
|
|
3
|
+
"version": "0.5.0-rc.31",
|
|
4
4
|
"description": "muster — a machine-local service that owns session agents across a fleet. Launcher: runs the prebuilt binary for this platform.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"homepage": "https://github.com/futurelastic/muster#readme",
|
|
@@ -20,10 +20,10 @@
|
|
|
20
20
|
"LICENSE"
|
|
21
21
|
],
|
|
22
22
|
"optionalDependencies": {
|
|
23
|
-
"@futurelastic/muster-darwin-arm64": "0.5.0-rc.
|
|
24
|
-
"@futurelastic/muster-darwin-x64": "0.5.0-rc.
|
|
25
|
-
"@futurelastic/muster-linux-x64": "0.5.0-rc.
|
|
26
|
-
"@futurelastic/muster-linux-arm64": "0.5.0-rc.
|
|
23
|
+
"@futurelastic/muster-darwin-arm64": "0.5.0-rc.31",
|
|
24
|
+
"@futurelastic/muster-darwin-x64": "0.5.0-rc.31",
|
|
25
|
+
"@futurelastic/muster-linux-x64": "0.5.0-rc.31",
|
|
26
|
+
"@futurelastic/muster-linux-arm64": "0.5.0-rc.31"
|
|
27
27
|
},
|
|
28
28
|
"publishConfig": {
|
|
29
29
|
"access": "public",
|