oysterun 1.6.0-beta.13 → 1.6.0-beta.14
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/host-service/onboard.mjs
CHANGED
|
@@ -118,14 +118,41 @@ function parseKeyValueStatus(output) {
|
|
|
118
118
|
function readServiceStatus() {
|
|
119
119
|
const result = service("status", [], { capture: true, allowFailure: true });
|
|
120
120
|
if ((result.status ?? 1) !== 0) {
|
|
121
|
-
return {
|
|
121
|
+
return {
|
|
122
|
+
available: false,
|
|
123
|
+
healthy: false,
|
|
124
|
+
running: false,
|
|
125
|
+
managed: false,
|
|
126
|
+
authenticated: false,
|
|
127
|
+
raw: {},
|
|
128
|
+
};
|
|
122
129
|
}
|
|
123
130
|
const raw = parseKeyValueStatus(result.stdout);
|
|
124
131
|
const pid = raw.pid && raw.pid !== "-" ? raw.pid : null;
|
|
132
|
+
const healthy = raw.health === "yes";
|
|
133
|
+
const managed = raw.loaded === "yes" && Boolean(pid);
|
|
134
|
+
let authenticated = false;
|
|
135
|
+
|
|
136
|
+
// A Host installed by an older Oysterun release can still be healthy while
|
|
137
|
+
// its process is absent from the current service manager's PID/label view.
|
|
138
|
+
// Prove that such a listener is this user's Host through the loopback-only
|
|
139
|
+
// service-control token before treating it as running. An unrelated process
|
|
140
|
+
// with a /health endpoint remains untrusted and is never stopped or adopted.
|
|
141
|
+
if (healthy && !managed) {
|
|
142
|
+
const control = service("lifecycle-status", [], {
|
|
143
|
+
capture: true,
|
|
144
|
+
allowFailure: true,
|
|
145
|
+
});
|
|
146
|
+
authenticated =
|
|
147
|
+
(control.status ?? 1) === 0 &&
|
|
148
|
+
Boolean(parseJsonOutput(control.stdout));
|
|
149
|
+
}
|
|
125
150
|
return {
|
|
126
151
|
available: true,
|
|
127
|
-
healthy
|
|
128
|
-
running:
|
|
152
|
+
healthy,
|
|
153
|
+
running: managed || authenticated,
|
|
154
|
+
managed,
|
|
155
|
+
authenticated,
|
|
129
156
|
raw,
|
|
130
157
|
};
|
|
131
158
|
}
|
package/package.json
CHANGED
package/static/site/install.sh
CHANGED
|
@@ -19,6 +19,7 @@ install_only=false
|
|
|
19
19
|
modify_path=true
|
|
20
20
|
package_install_spec=""
|
|
21
21
|
requested_channel_override=""
|
|
22
|
+
version_compare_script='const p=v=>{const m=String(v).match(/^(\d+)\.(\d+)\.(\d+)(?:-([0-9A-Za-z.-]+))?$/);return m?[+m[1],+m[2],+m[3],m[4]||""]:null},a=p(process.argv[1]),b=p(process.argv[2]);if(!a||!b)process.exit(2);let result=null;for(let i=0;i<3;i++){if(a[i]!==b[i]){result=a[i]>b[i]?1:-1;break}}if(result===null){if(a[3]===b[3])result=0;else if(!a[3])result=1;else if(!b[3])result=-1;else result=a[3].localeCompare(b[3],undefined,{numeric:true})>0?1:-1}console.log(result)'
|
|
22
23
|
|
|
23
24
|
cleanup() {
|
|
24
25
|
local exit_status=$?
|
|
@@ -322,7 +323,7 @@ else
|
|
|
322
323
|
selected_version="$(capture_user env PATH="$managed_runtime_path" NPM_CONFIG_PREFIX="$npm_prefix" "$node_bin" "$npm_cli" view "oysterun@$requested_spec" version --json | "$node_bin" -e 'let s="";process.stdin.on("data",d=>s+=d).on("end",()=>{const v=JSON.parse(s);process.stdout.write(Array.isArray(v)?v[v.length-1]:v)})')"
|
|
323
324
|
[[ "$selected_version" =~ ^[0-9]+\.[0-9]+\.[0-9]+([+-][0-9A-Za-z.-]+)?$ ]] || fail "npm returned an invalid Oysterun version"
|
|
324
325
|
if [[ -n "$installed_version" && -z "$recorded_channel" ]]; then
|
|
325
|
-
comparison="$("$node_bin" -e
|
|
326
|
+
comparison="$("$node_bin" -e "$version_compare_script" "$selected_version" "$installed_version")"
|
|
326
327
|
if [[ "$comparison" == "-1" ]]; then
|
|
327
328
|
selected_channel="exact:$installed_version"
|
|
328
329
|
selected_version="$installed_version"
|
|
@@ -19,6 +19,7 @@ install_only=false
|
|
|
19
19
|
modify_path=true
|
|
20
20
|
package_install_spec=""
|
|
21
21
|
requested_channel_override=""
|
|
22
|
+
version_compare_script='const p=v=>{const m=String(v).match(/^(\d+)\.(\d+)\.(\d+)(?:-([0-9A-Za-z.-]+))?$/);return m?[+m[1],+m[2],+m[3],m[4]||""]:null},a=p(process.argv[1]),b=p(process.argv[2]);if(!a||!b)process.exit(2);let result=null;for(let i=0;i<3;i++){if(a[i]!==b[i]){result=a[i]>b[i]?1:-1;break}}if(result===null){if(a[3]===b[3])result=0;else if(!a[3])result=1;else if(!b[3])result=-1;else result=a[3].localeCompare(b[3],undefined,{numeric:true})>0?1:-1}console.log(result)'
|
|
22
23
|
|
|
23
24
|
cleanup() {
|
|
24
25
|
local exit_status=$?
|
|
@@ -322,7 +323,7 @@ else
|
|
|
322
323
|
selected_version="$(capture_user env PATH="$managed_runtime_path" NPM_CONFIG_PREFIX="$npm_prefix" "$node_bin" "$npm_cli" view "oysterun@$requested_spec" version --json | "$node_bin" -e 'let s="";process.stdin.on("data",d=>s+=d).on("end",()=>{const v=JSON.parse(s);process.stdout.write(Array.isArray(v)?v[v.length-1]:v)})')"
|
|
323
324
|
[[ "$selected_version" =~ ^[0-9]+\.[0-9]+\.[0-9]+([+-][0-9A-Za-z.-]+)?$ ]] || fail "npm returned an invalid Oysterun version"
|
|
324
325
|
if [[ -n "$installed_version" && -z "$recorded_channel" ]]; then
|
|
325
|
-
comparison="$("$node_bin" -e
|
|
326
|
+
comparison="$("$node_bin" -e "$version_compare_script" "$selected_version" "$installed_version")"
|
|
326
327
|
if [[ "$comparison" == "-1" ]]; then
|
|
327
328
|
selected_channel="exact:$installed_version"
|
|
328
329
|
selected_version="$installed_version"
|