Skip to content

Commit f6d5a5d

Browse files
committed
Include nodemon config in build artifact
1 parent 31af99e commit f6d5a5d

34 files changed

+433
-1225
lines changed

api/ecosystem.config.json

Lines changed: 0 additions & 22 deletions
This file was deleted.

api/generated-schema.graphql

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1673,8 +1673,8 @@ type PackageVersions {
16731673
"""npm version"""
16741674
npm: String
16751675

1676-
"""pm2 version"""
1677-
pm2: String
1676+
"""nodemon version"""
1677+
nodemon: String
16781678

16791679
"""Git version"""
16801680
git: String

api/legacy/generated-schema-legacy.graphql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1257,7 +1257,7 @@ type Versions {
12571257
openssl: String
12581258
perl: String
12591259
php: String
1260-
pm2: String
1260+
nodemon: String
12611261
postfix: String
12621262
postgresql: String
12631263
python: String

api/nodemon.json

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"watch": [
3+
"dist/main.js",
4+
"myservers.cfg"
5+
],
6+
"ignore": [
7+
"node_modules",
8+
"src",
9+
".env.*"
10+
],
11+
"exec": "node ./dist/main.js",
12+
"signal": "SIGTERM",
13+
"ext": "js,json",
14+
"restartable": "rs",
15+
"env": {
16+
"NODE_ENV": "production"
17+
}
18+
}

api/package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@
137137
"pino": "9.9.0",
138138
"pino-http": "10.5.0",
139139
"pino-pretty": "13.1.1",
140-
"pm2": "6.0.8",
140+
"nodemon": "3.1.10",
141141
"reflect-metadata": "^0.1.14",
142142
"rxjs": "7.8.2",
143143
"semver": "7.7.2",
@@ -203,7 +203,6 @@
203203
"eslint-plugin-no-relative-import-paths": "1.6.1",
204204
"eslint-plugin-prettier": "5.5.4",
205205
"jiti": "2.5.1",
206-
"nodemon": "3.1.10",
207206
"prettier": "3.6.2",
208207
"rollup-plugin-node-externals": "8.1.0",
209208
"supertest": "7.1.4",

api/scripts/build.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { exit } from 'process';
77
import type { PackageJson } from 'type-fest';
88
import { $, cd } from 'zx';
99

10-
import { getDeploymentVersion } from './get-deployment-version.js';
10+
import { getDeploymentVersion } from '@app/../scripts/get-deployment-version.js';
1111

1212
type ApiPackageJson = PackageJson & {
1313
version: string;
@@ -94,7 +94,7 @@ try {
9494

9595
await writeFile('./deploy/pack/package.json', JSON.stringify(parsedPackageJson, null, 4));
9696
// Copy necessary files to the pack directory
97-
await $`cp -r dist README.md .env.* ecosystem.config.json ./deploy/pack/`;
97+
await $`cp -r dist README.md .env.* nodemon.json ./deploy/pack/`;
9898

9999
// Change to the pack directory and install dependencies
100100
cd('./deploy/pack');

api/src/__test__/core/utils/pm2/dummy-process.js

Lines changed: 0 additions & 5 deletions
This file was deleted.

api/src/__test__/core/utils/pm2/unraid-api-running.integration.test.ts

Lines changed: 0 additions & 222 deletions
This file was deleted.
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
import { mkdtempSync, rmSync, writeFileSync } from 'node:fs';
2+
import { tmpdir } from 'node:os';
3+
import { join } from 'node:path';
4+
5+
import { afterAll, afterEach, beforeAll, describe, expect, it, vi } from 'vitest';
6+
7+
describe('isUnraidApiRunning (nodemon pid detection)', () => {
8+
let tempDir: string;
9+
let pidPath: string;
10+
11+
beforeAll(() => {
12+
tempDir = mkdtempSync(join(tmpdir(), 'unraid-api-'));
13+
pidPath = join(tempDir, 'nodemon.pid');
14+
});
15+
16+
afterAll(() => {
17+
rmSync(tempDir, { recursive: true, force: true });
18+
});
19+
20+
afterEach(() => {
21+
vi.resetModules();
22+
});
23+
24+
async function loadIsRunning() {
25+
vi.doMock('@app/environment.js', async () => {
26+
const actual =
27+
await vi.importActual<typeof import('@app/environment.js')>('@app/environment.js');
28+
return { ...actual, NODEMON_PID_PATH: pidPath };
29+
});
30+
31+
const module = await import('@app/core/utils/process/unraid-api-running.js');
32+
return module.isUnraidApiRunning;
33+
}
34+
35+
it('returns false when pid file is missing', async () => {
36+
const isUnraidApiRunning = await loadIsRunning();
37+
38+
expect(await isUnraidApiRunning()).toBe(false);
39+
});
40+
41+
it('returns true when a live pid is recorded', async () => {
42+
writeFileSync(pidPath, `${process.pid}`);
43+
const isUnraidApiRunning = await loadIsRunning();
44+
45+
expect(await isUnraidApiRunning()).toBe(true);
46+
});
47+
48+
it('returns false when pid file is invalid', async () => {
49+
writeFileSync(pidPath, 'not-a-number');
50+
const isUnraidApiRunning = await loadIsRunning();
51+
52+
expect(await isUnraidApiRunning()).toBe(false);
53+
});
54+
});

api/src/core/log.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,15 @@ const nullDestination = pino.destination({
1717

1818
export const logDestination =
1919
process.env.SUPPRESS_LOGS === 'true' ? nullDestination : pino.destination();
20-
// Since PM2 captures stdout and writes to the log file, we should not colorize stdout
20+
// Since process output is piped directly to the log file, we should not colorize stdout
2121
// to avoid ANSI escape codes in the log file
2222
const stream = SUPPRESS_LOGS
2323
? nullDestination
2424
: LOG_TYPE === 'pretty'
2525
? pretty({
2626
singleLine: true,
2727
hideObject: false,
28-
colorize: false, // No colors since PM2 writes stdout to file
28+
colorize: false, // No colors since logs are written directly to file
2929
colorizeObjects: false,
3030
levelFirst: false,
3131
ignore: 'hostname,pid',

0 commit comments

Comments
 (0)