@dxos/phoenix 0.8.4-main.ae835ea → 0.8.4-main.bc2380dfbc
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 +102 -5
- package/README.md +1 -1
- package/bin/watchdog.mjs +5 -0
- package/dist/lib/node-esm/index.mjs +6 -37
- package/dist/lib/node-esm/index.mjs.map +3 -3
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/types/src/phoenix.d.ts +2 -2
- package/dist/types/src/phoenix.d.ts.map +1 -1
- package/dist/types/src/testing-utils.d.ts.map +1 -1
- package/dist/types/src/utils.d.ts.map +1 -1
- package/dist/types/src/watchdog.d.ts +3 -3
- package/dist/types/src/watchdog.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +10 -9
- package/src/phoenix.node.test.ts +6 -6
- package/src/phoenix.ts +2 -3
- package/src/watchdog.node.test.ts +0 -1
- package/src/watchdog.ts +3 -3
package/package.json
CHANGED
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dxos/phoenix",
|
|
3
|
-
"version": "0.8.4-main.
|
|
3
|
+
"version": "0.8.4-main.bc2380dfbc",
|
|
4
4
|
"description": "Basic node daemon.",
|
|
5
5
|
"homepage": "https://dxos.org",
|
|
6
6
|
"bugs": "https://github.com/dxos/dxos/issues",
|
|
7
|
-
"
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "https://github.com/dxos/dxos"
|
|
10
|
+
},
|
|
11
|
+
"license": "FSL-1.1-Apache-2.0",
|
|
8
12
|
"author": "DXOS.org",
|
|
9
13
|
"sideEffects": true,
|
|
10
14
|
"type": "module",
|
|
@@ -16,9 +20,6 @@
|
|
|
16
20
|
}
|
|
17
21
|
},
|
|
18
22
|
"types": "dist/types/src/index.d.ts",
|
|
19
|
-
"typesVersions": {
|
|
20
|
-
"*": {}
|
|
21
|
-
},
|
|
22
23
|
"files": [
|
|
23
24
|
"bin",
|
|
24
25
|
"dist",
|
|
@@ -26,10 +27,10 @@
|
|
|
26
27
|
],
|
|
27
28
|
"dependencies": {
|
|
28
29
|
"pkg-up": "^3.1.0",
|
|
29
|
-
"@dxos/
|
|
30
|
-
"@dxos/invariant": "0.8.4-main.
|
|
31
|
-
"@dxos/log": "0.8.4-main.
|
|
32
|
-
"@dxos/
|
|
30
|
+
"@dxos/node-std": "0.8.4-main.bc2380dfbc",
|
|
31
|
+
"@dxos/invariant": "0.8.4-main.bc2380dfbc",
|
|
32
|
+
"@dxos/log": "0.8.4-main.bc2380dfbc",
|
|
33
|
+
"@dxos/async": "0.8.4-main.bc2380dfbc"
|
|
33
34
|
},
|
|
34
35
|
"publishConfig": {
|
|
35
36
|
"access": "public"
|
package/src/phoenix.node.test.ts
CHANGED
|
@@ -3,9 +3,8 @@
|
|
|
3
3
|
//
|
|
4
4
|
|
|
5
5
|
import { spawn } from 'node:child_process';
|
|
6
|
-
import {
|
|
6
|
+
import { readFileSync } from 'node:fs';
|
|
7
7
|
import { join } from 'node:path';
|
|
8
|
-
|
|
9
8
|
import { describe, expect, onTestFinished, test } from 'vitest';
|
|
10
9
|
|
|
11
10
|
import { Trigger } from '@dxos/async';
|
|
@@ -25,7 +24,6 @@ describe.skipIf(process.env.CI)('DaemonManager', () => {
|
|
|
25
24
|
await trigger.wait({ timeout: 1_000 });
|
|
26
25
|
});
|
|
27
26
|
|
|
28
|
-
// Fails on CI
|
|
29
27
|
test('start/stop detached watchdog', async () => {
|
|
30
28
|
const runId = Math.random().toString();
|
|
31
29
|
const pidFile = join(TEST_DIR, `pid-${runId}.pid`);
|
|
@@ -45,9 +43,11 @@ describe.skipIf(process.env.CI)('DaemonManager', () => {
|
|
|
45
43
|
errFile,
|
|
46
44
|
});
|
|
47
45
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
expect
|
|
46
|
+
// Poll for log content directly — the file is pre-created empty by Phoenix.start(),
|
|
47
|
+
// so polling for existence would resolve immediately before the child writes its output.
|
|
48
|
+
await expect
|
|
49
|
+
.poll(() => readFileSync(params.logFile, { encoding: 'utf-8' }), { timeout: 5000 })
|
|
50
|
+
.toContain('neverEndingProcess started');
|
|
51
51
|
}
|
|
52
52
|
|
|
53
53
|
// Stop
|
package/src/phoenix.ts
CHANGED
|
@@ -5,14 +5,13 @@
|
|
|
5
5
|
import { fork } from 'node:child_process';
|
|
6
6
|
import { existsSync, mkdirSync, readFileSync, unlinkSync, writeFileSync } from 'node:fs';
|
|
7
7
|
import { dirname, join } from 'node:path';
|
|
8
|
-
|
|
9
8
|
import pkgUp from 'pkg-up';
|
|
10
9
|
|
|
11
10
|
import { invariant } from '@dxos/invariant';
|
|
12
11
|
import { log } from '@dxos/log';
|
|
13
12
|
|
|
14
13
|
import { waitForPidDeletion, waitForPidFileBeingFilledWithInfo } from './utils';
|
|
15
|
-
import { type ProcessInfo, type
|
|
14
|
+
import { type ProcessInfo, type WatchDogProps } from './watchdog';
|
|
16
15
|
|
|
17
16
|
const scriptDir = typeof __dirname === 'string' ? __dirname : dirname(new URL(import.meta.url).pathname);
|
|
18
17
|
|
|
@@ -23,7 +22,7 @@ export class Phoenix {
|
|
|
23
22
|
/**
|
|
24
23
|
* Starts detached watchdog process which starts and monitors selected command.
|
|
25
24
|
*/
|
|
26
|
-
static async start(params:
|
|
25
|
+
static async start(params: WatchDogProps): Promise<ProcessInfo> {
|
|
27
26
|
{
|
|
28
27
|
// Clear stale pid file.
|
|
29
28
|
if (existsSync(params.pidFile)) {
|
package/src/watchdog.ts
CHANGED
|
@@ -12,14 +12,14 @@ import { log } from '@dxos/log';
|
|
|
12
12
|
|
|
13
13
|
import { waitForPidDeletion, waitForPidFileBeingFilledWithInfo } from './utils';
|
|
14
14
|
|
|
15
|
-
export type ProcessInfo =
|
|
15
|
+
export type ProcessInfo = WatchDogProps & {
|
|
16
16
|
pid?: number;
|
|
17
17
|
started?: number;
|
|
18
18
|
restarts?: number;
|
|
19
19
|
running?: boolean;
|
|
20
20
|
};
|
|
21
21
|
|
|
22
|
-
export type
|
|
22
|
+
export type WatchDogProps = {
|
|
23
23
|
profile?: string; // Human readable process identifier
|
|
24
24
|
pidFile: string; // Path to PID file
|
|
25
25
|
|
|
@@ -56,7 +56,7 @@ export class WatchDog {
|
|
|
56
56
|
private _child?: ChildProcessWithoutNullStreams;
|
|
57
57
|
private _restarts = 0;
|
|
58
58
|
|
|
59
|
-
constructor(private readonly _params:
|
|
59
|
+
constructor(private readonly _params: WatchDogProps) {}
|
|
60
60
|
|
|
61
61
|
@synchronized
|
|
62
62
|
async start(): Promise<void> {
|