Compare commits

...

1 Commits

Author SHA1 Message Date
Craigory Coppola 4fc0a47a7a fix(core): add registerExitHandler utility 2025-05-08 13:30:32 -04:00
44 changed files with 142 additions and 175 deletions
@@ -45,7 +45,6 @@ export function runCliBuild(
// Ensure the child process is killed when the parent exits
process.on('exit', () => childProcess.kill());
process.on('SIGTERM', () => childProcess.kill());
childProcess.on('error', (err) => {
reject(err);
@@ -66,7 +66,6 @@ function runCliTest(
// Ensure the child process is killed when the parent exits
process.on('exit', () => childProcess.kill());
process.on('SIGTERM', () => childProcess.kill());
childProcess.on('error', (err) => {
reject(err);
@@ -173,7 +173,7 @@ export async function* esbuildExecutor(
})
);
registerCleanupCallback(() => {
process.once('exit', () => {
assetsResult?.stop();
packageJsonResult?.stop();
disposeFns.forEach((fn) => fn());
@@ -269,17 +269,4 @@ async function runTypeCheck(
return { errors, warnings };
}
function registerCleanupCallback(callback: () => void) {
const wrapped = () => {
callback();
process.off('SIGINT', wrapped);
process.off('SIGTERM', wrapped);
process.off('exit', wrapped);
};
process.on('SIGINT', wrapped);
process.on('SIGTERM', wrapped);
process.on('exit', wrapped);
}
export default esbuildExecutor;
@@ -52,7 +52,6 @@ export function runCliBuildList(
// Ensure the child process is killed when the parent exits
process.on('exit', () => childProcess.kill());
process.on('SIGTERM', () => childProcess.kill());
let output = '';
childProcess.stdout.on('data', (message) => {
@@ -68,7 +68,6 @@ function runCliBuild(
// Ensure the child process is killed when the parent exits
process.on('exit', () => childProcess.kill());
process.on('SIGTERM', () => childProcess.kill());
childProcess.on('error', (err) => {
reject(err);
@@ -48,7 +48,6 @@ function exportAsync(
// Ensure the child process is killed when the parent exits
process.on('exit', () => childProcess.kill());
process.on('SIGTERM', () => childProcess.kill());
childProcess.on('error', (err) => {
reject(err);
@@ -55,7 +55,6 @@ export function prebuildAsync(
// Ensure the child process is killed when the parent exits
process.on('exit', () => childProcess.kill());
process.on('SIGTERM', () => childProcess.kill());
childProcess.on('error', (err) => {
reject(err);
@@ -70,7 +70,6 @@ function runCliRun(
// Ensure the child process is killed when the parent exits
process.on('exit', () => childProcess.kill());
process.on('SIGTERM', () => childProcess.kill());
childProcess.on('error', (err) => {
reject(err);
@@ -56,7 +56,6 @@ function startAsync(
// Ensure the child process is killed when the parent exits
process.on('exit', () => childProcess.kill());
process.on('SIGTERM', () => childProcess.kill());
childProcess.on('error', (err) => {
reject(err);
@@ -47,7 +47,6 @@ function runCliSubmit(
// Ensure the child process is killed when the parent exits
process.on('exit', () => childProcess.kill());
process.on('SIGTERM', () => childProcess.kill());
childProcess.on('error', (err) => {
reject(err);
@@ -47,7 +47,6 @@ function runCliUpdate(
// Ensure the child process is killed when the parent exits
process.on('exit', () => childProcess.kill());
process.on('SIGTERM', () => childProcess.kill());
childProcess.on('error', (err) => {
reject(err);
+6 -12
View File
@@ -22,6 +22,7 @@ import { killTree } from './lib/kill-tree';
import { fileExists } from 'nx/src/utils/fileutils';
import { getRelativeDirectoryToProjectRoot } from '../../utils/get-main-file-dir';
import { interpolate } from 'nx/src/tasks-runner/utils';
import { registerExitHandler } from 'nx/src/utils/signals';
interface ActiveTask {
id: string;
@@ -233,18 +234,11 @@ export async function* nodeExecutor(
}
};
process.on('SIGTERM', async () => {
await stopAllTasks('SIGTERM');
process.exit(128 + 15);
});
process.on('SIGINT', async () => {
await stopAllTasks('SIGINT');
process.exit(128 + 2);
});
process.on('SIGHUP', async () => {
await stopAllTasks('SIGHUP');
process.exit(128 + 1);
});
for (const signal of ['SIGTERM', 'SIGINT', 'SIGHUP'] as const) {
registerExitHandler('SIGTERM', async () => {
await stopAllTasks(signal);
});
}
registerCleanup(async () => {
await stopAllTasks('SIGTERM');
+3 -2
View File
@@ -28,6 +28,7 @@ import { compileSwc, compileSwcWatch } from '../../utils/swc/compile-swc';
import { getSwcrcPath } from '../../utils/swc/get-swcrc-path';
import { generateTmpSwcrc } from '../../utils/swc/inline';
import { isUsingTsSolutionSetup } from '../../utils/typescript/ts-solution-setup';
import { registerExitHandler } from 'nx/src/utils/signals';
function normalizeOptions(
options: SwcExecutorOptions,
@@ -186,8 +187,8 @@ export async function* swcExecutor(
if (options.watch) {
let disposeFn: () => void;
process.on('SIGINT', () => disposeFn());
process.on('SIGTERM', () => disposeFn());
registerExitHandler('SIGINT', (s) => disposeFn());
registerExitHandler('SIGTERM', (s) => disposeFn());
return yield* compileSwcWatch(context, options, async () => {
const assetResult = await copyAssets(options, context);
@@ -27,6 +27,7 @@ import {
watchTaskProjectsPackageJsonFileChanges,
} from './lib/batch';
import { createEntryPoints } from '../../utils/package-json/create-entry-points';
import { registerExitHandler } from 'nx/src/utils/signals';
export async function* tscBatchExecutor(
taskGraph: TaskGraph,
@@ -150,13 +151,12 @@ export async function* tscBatchExecutor(
}
);
const handleTermination = async (exitCode: number) => {
const handleTermination = async () => {
watchAssetsChangesDisposer();
watchProjectsChangesDisposer();
process.exit(exitCode);
};
process.on('SIGINT', () => handleTermination(128 + 2));
process.on('SIGTERM', () => handleTermination(128 + 15));
registerExitHandler('SIGINT', (s) => handleTermination());
registerExitHandler('SIGTERM', (s) => handleTermination());
return yield* mapAsyncIterable(typescriptCompilation, async (iterator) => {
// drain the iterator, we don't use the results
+4 -4
View File
@@ -24,6 +24,7 @@ import { watchForSingleFileChanges } from '../../utils/watch-for-single-file-cha
import { getCustomTrasformersFactory, normalizeOptions } from './lib';
import { readTsConfig } from '../../utils/typescript/ts-config';
import { createEntryPoints } from '../../utils/package-json/create-entry-points';
import { registerExitHandler } from 'nx/src/utils/signals';
export function determineModuleFormatFromTsConfig(
absolutePathToTsConfig: string
@@ -169,14 +170,13 @@ export async function* tscExecutor(
)
);
}
const handleTermination = async (exitCode: number) => {
const handleTermination = async () => {
await typescriptCompilation.close();
disposeWatchAssetChanges();
disposePackageJsonChanges?.();
process.exit(exitCode);
};
process.on('SIGINT', () => handleTermination(128 + 2));
process.on('SIGTERM', () => handleTermination(128 + 15));
registerExitHandler('SIGINT', (s) => handleTermination());
registerExitHandler('SIGTERM', (s) => handleTermination());
}
return yield* typescriptCompilation.iterator;
@@ -57,9 +57,6 @@ export async function verdaccioExecutor(
}
};
process.on('exit', processExitListener);
process.on('SIGTERM', processExitListener);
process.on('SIGINT', processExitListener);
process.on('SIGHUP', processExitListener);
try {
await startVerdaccio(options, context.root);
-2
View File
@@ -229,8 +229,6 @@ export async function* compileSwcWatch(
swcWatcher.stdout.on('data', stdoutOnData);
swcWatcher.stderr.on('data', stderrOnData);
process.on('SIGINT', processOnExit);
process.on('SIGTERM', processOnExit);
process.on('exit', processOnExit);
swcWatcher.on('exit', watcherOnExit);
@@ -87,7 +87,6 @@ export async function buildStaticRemotes(
res();
}
});
process.on('SIGTERM', () => staticProcess.kill('SIGTERM'));
process.on('exit', () => staticProcess.kill('SIGTERM'));
});
@@ -130,9 +130,6 @@ export class NxModuleFederationSSRDevServerPlugin
process.on('exit', () => {
this.devServerProcess?.kill('SIGKILL');
});
process.on('SIGINT', () => {
this.devServerProcess?.kill('SIGKILL');
});
callback();
});
}
@@ -76,7 +76,6 @@ export async function buildStaticRemotes(
res();
}
});
process.on('SIGTERM', () => staticProcess.kill('SIGTERM'));
process.on('exit', () => staticProcess.kill('SIGTERM'));
});
@@ -55,7 +55,6 @@ export function startRemoteProxies(
const proxyServer = (sslCert ? https : http)
.createServer({ cert: sslCert, key: sslKey }, expressProxy)
.listen(appConfig.port);
process.on('SIGTERM', () => proxyServer.close());
process.on('exit', () => proxyServer.close());
}
console.info(`NX Static remotes proxies started successfully`);
@@ -58,6 +58,5 @@ export function startStaticRemotesFileServer(
},
}
);
process.on('SIGTERM', () => httpServerProcess.kill('SIGTERM'));
process.on('exit', () => httpServerProcess.kill('SIGTERM'));
}
@@ -41,7 +41,6 @@ export function startRemoteProxies(
const proxyServer = (sslCert ? https : http)
.createServer({ cert: sslCert, key: sslKey }, expressProxy)
.listen(staticRemotesConfig.config[app].port);
process.on('SIGTERM', () => proxyServer.close());
process.on('exit', () => proxyServer.close());
}
logger.info(`NX Static remotes proxies started successfully`);
@@ -58,7 +58,6 @@ export function startSsrRemoteProxies(
const proxyServer = (sslCert ? https : http)
.createServer({ cert: sslCert, key: sslKey }, expressProxy)
.listen(staticRemotesConfig.config[app].port);
process.on('SIGTERM', () => proxyServer.close());
process.on('exit', () => proxyServer.close());
}
logger.info(`Nx SSR Static remotes proxies started successfully`);
@@ -20,6 +20,7 @@ import { NextBuildBuilderOptions } from '../../utils/types';
import { ChildProcess, fork } from 'child_process';
import { createCliOptions } from '../../utils/create-cli-options';
import { signalToCode } from 'nx/src/utils/exit-codes';
import { registerExitHandler } from 'nx/src/utils/signals';
let childProcess: ChildProcess;
@@ -157,12 +158,11 @@ function runCliBuild(
// Ensure the child process is killed when the parent exits
process.on('exit', () => childProcess.kill());
process.on('SIGTERM', (signal) => {
reject({ code: signalToCode(signal), signal });
});
process.on('SIGINT', (signal) => {
reject({ code: signalToCode(signal), signal });
});
for (const signal of ['SIGINT', 'SIGTERM'] as const) {
registerExitHandler(signal, () => {
reject({ code: signalToCode(signal), signal });
});
}
childProcess.on('error', (err) => {
reject({ error: err });
@@ -82,9 +82,6 @@ export default async function* serveExecutor(
}
};
process.on('exit', () => killServer());
process.on('SIGINT', () => killServer());
process.on('SIGTERM', () => killServer());
process.on('SIGHUP', () => killServer());
await waitForPortOpen(options.port, { host: options.hostname });
+6 -19
View File
@@ -21,7 +21,7 @@ import { performance } from 'perf_hooks';
import { setupWorkspaceContext } from '../src/utils/workspace-context';
import { daemonClient } from '../src/daemon/client/client';
import { removeDbConnections } from '../src/utils/db-connection';
import { signalToCode } from '../src/utils/exit-codes';
import { registerExitHandler } from '../src/utils/signals';
// In case Nx Cloud forcibly exits while the TUI is running, ensure the terminal is restored etc.
process.on('exit', (...args) => {
@@ -283,26 +283,13 @@ const getLatestVersionOfNx = ((fn: () => string) => {
return () => cache || (cache = fn());
})(_getLatestVersionOfNx);
function nxCleanup(signal?: NodeJS.Signals) {
function nxCleanup() {
removeDbConnections();
if (signal) {
process.exit(signalToCode(signal));
} else {
process.exit();
}
}
process.on('exit', () => {
nxCleanup();
});
process.on('SIGINT', () => {
nxCleanup('SIGINT');
});
process.on('SIGTERM', () => {
nxCleanup('SIGTERM');
});
process.on('SIGHUP', () => {
nxCleanup('SIGHUP');
});
registerExitHandler('SIGINT', nxCleanup);
registerExitHandler('SIGTERM', nxCleanup);
registerExitHandler('SIGHUP', nxCleanup);
registerExitHandler('exit', nxCleanup);
main();
+4 -1
View File
@@ -1,7 +1,10 @@
import { appendFileSync, openSync, writeFileSync } from 'fs';
import { Target, run } from '../src/command-line/run/run';
import { TaskGraph } from '../src/config/task-graph';
import { Target, run } from '../src/command-line/run/run';
import '../src/utils/signals';
if (process.env.NX_TERMINAL_OUTPUT_PATH) {
setUpOutputWatching(
process.env.NX_TERMINAL_CAPTURE_STDERR === 'true',
+9 -4
View File
@@ -57,6 +57,7 @@ import { ConfigurationSourceMaps } from '../../project-graph/utils/project-confi
import { createTaskHasher } from '../../hasher/create-task-hasher';
import { ProjectGraphError } from '../../project-graph/error-types';
import { isNxCloudUsed } from '../../utils/nx-cloud-utils';
import { registerExitHandler } from '../../utils/signals';
export interface GraphError {
message: string;
@@ -667,14 +668,18 @@ async function startServer(
}
});
const handleTermination = async (exitCode: number) => {
const handleTermination = async () => {
if (unregisterFileWatcher) {
unregisterFileWatcher();
}
process.exit(exitCode);
};
process.on('SIGINT', () => handleTermination(128 + 2));
process.on('SIGTERM', () => handleTermination(128 + 15));
registerExitHandler('SIGINT', () => {
handleTermination();
});
registerExitHandler('SIGTERM', () => {
handleTermination();
});
return new Promise<{ app: Server; url: URL }>((res) => {
app.listen(port, host, () => {
@@ -14,12 +14,12 @@ import {
loadAndExpandDotEnvFile,
unloadDotEnvFile,
} from '../../tasks-runner/task-env';
import { signalToCode } from '../../utils/exit-codes';
import {
LARGE_BUFFER,
NormalizedRunCommandsOptions,
RunCommandsCommandOptions,
} from './run-commands.impl';
import { registerExitHandler } from '../../utils/signals';
export class ParallelRunningTasks implements RunningTask {
private readonly childProcesses: RunningNodeProcess[];
@@ -594,23 +594,8 @@ function registerProcessListener(
}
});
// Terminate any task processes on exit
process.on('exit', () => {
runningTask.kill();
});
process.on('SIGINT', () => {
runningTask.kill('SIGTERM');
// we exit here because we don't need to write anything to cache.
process.exit(signalToCode('SIGINT'));
});
process.on('SIGTERM', () => {
runningTask.kill('SIGTERM');
// no exit here because we expect child processes to terminate which
// will store results to the cache and will terminate this process
});
process.on('SIGHUP', () => {
runningTask.kill('SIGTERM');
// no exit here because we expect child processes to terminate which
// will store results to the cache and will terminate this process
});
registerExitHandler('exit', () => runningTask.kill());
registerExitHandler('SIGINT', () => runningTask.kill('SIGINT'));
registerExitHandler('SIGTERM', () => runningTask.kill('SIGTERM'));
registerExitHandler('SIGHUP', () => runningTask.kill('SIGHUP'));
}
@@ -7,7 +7,7 @@ import {
PseudoTtyProcess,
} from '../../tasks-runner/pseudo-terminal';
import { getPackageManagerCommand } from '../../utils/package-manager';
import { signalToCode } from '../../utils/exit-codes';
import { registerExitHandler } from '../../utils/signals';
export interface RunScriptOptions {
script: string;
@@ -84,16 +84,6 @@ async function ptyProcess(
});
}
// TODO: This only works because pseudo terminal registers signal handlers first but we need a service to handle this
process.on('SIGHUP', () => {
cp.kill('SIGHUP');
process.exit(signalToCode('SIGHUP'));
});
process.on('SIGTERM', () => {
cp.kill('SIGTERM');
process.exit(signalToCode('SIGTERM'));
});
process.on('SIGINT', () => {
cp.kill('SIGINT');
process.exit(signalToCode('SIGINT'));
});
registerExitHandler('SIGINT', () => cp.kill('SIGINT'));
registerExitHandler('SIGTERM', () => cp.kill('SIGTERM'));
registerExitHandler('SIGHUP', () => cp.kill('SIGHUP'));
+6 -15
View File
@@ -1,7 +1,7 @@
import { fork, Serializable } from 'child_process';
import { join } from 'path';
import { PseudoIPCClient } from './pseudo-ipc';
import { signalToCode } from '../utils/exit-codes';
import { registerExitHandler } from '../utils/signals';
const pseudoIPCPath = process.argv[2];
const forkId = process.argv[3];
@@ -37,17 +37,8 @@ childProcess.on('exit', (code) => {
process.exit(code);
});
// Terminate the child process when exiting
process.on('exit', () => {
childProcess.kill();
});
process.on('SIGINT', () => {
childProcess.kill('SIGTERM');
process.exit(signalToCode('SIGINT'));
});
process.on('SIGTERM', () => {
childProcess.kill('SIGTERM');
});
process.on('SIGHUP', () => {
childProcess.kill('SIGTERM');
});
registerExitHandler('exit', () => childProcess.kill());
for (const signal of ['SIGINT', 'SIGTERM', 'SIGHUP'] as const) {
registerExitHandler(signal, () => childProcess.kill(signal));
}
@@ -9,6 +9,7 @@ import { Task } from '../../config/task-graph';
import { prettyTime } from './pretty-time';
import { formatFlags, formatTargetsAndProjects } from './formatting-utils';
import { viewLogsFooterRows } from './view-logs-utils';
import { registerExitHandler } from '../../utils/signals';
const LEFT_PAD = ` `;
const SPACER = ` `;
@@ -54,10 +55,9 @@ export async function createRunManyDynamicOutputRenderer({
}
}
process.on('exit', () => clearRenderInterval());
process.on('SIGINT', () => clearRenderInterval());
process.on('SIGTERM', () => clearRenderInterval());
process.on('SIGHUP', () => clearRenderInterval());
for (const signal of ['SIGINT', 'SIGTERM', 'SIGHUP', 'exit'] as const) {
registerExitHandler(signal, () => clearRenderInterval());
}
const lifeCycle = {} as Partial<LifeCycle>;
const isVerbose = overrides.verbose === true;
@@ -8,6 +8,7 @@ import { prettyTime } from './pretty-time';
import { Task } from '../../config/task-graph';
import { formatFlags, formatTargetsAndProjects } from './formatting-utils';
import { viewLogsFooterRows } from './view-logs-utils';
import { registerExitHandler } from '../../utils/signals';
const LEFT_PAD = ` `;
const SPACER = ` `;
@@ -65,10 +66,7 @@ export async function createRunOneDynamicOutputRenderer({
}
}
process.on('exit', () => clearRenderInterval());
process.on('SIGINT', () => clearRenderInterval());
process.on('SIGTERM', () => clearRenderInterval());
process.on('SIGHUP', () => clearRenderInterval());
registerExitHandler('exit', () => clearRenderInterval());
const lifeCycle = {} as Partial<LifeCycle>;
@@ -4,19 +4,21 @@ import { getForkedProcessOsSocketPath } from '../daemon/socket-utils';
import { ChildProcess, IS_WASM, RustPseudoTerminal } from '../native';
import { PseudoIPCServer } from './pseudo-ipc';
import { RunningTask } from './running-tasks/running-task';
import { registerExitHandler } from '../utils/signals';
// Register single event listeners for all pseudo-terminal instances
const pseudoTerminalShutdownCallbacks: Array<(s?: NodeJS.Signals) => void> = [];
process.on('SIGINT', () => {
registerExitHandler('SIGINT', () => {
pseudoTerminalShutdownCallbacks.forEach((cb) => cb('SIGINT'));
});
process.on('SIGTERM', () => {
registerExitHandler('SIGTERM', () => {
pseudoTerminalShutdownCallbacks.forEach((cb) => cb('SIGTERM'));
});
process.on('SIGHUP', () => {
registerExitHandler('SIGHUP', () => {
pseudoTerminalShutdownCallbacks.forEach((cb) => cb('SIGHUP'));
});
process.on('exit', () => {
registerExitHandler('exit', () => {
pseudoTerminalShutdownCallbacks.forEach((cb) => cb());
});
+13
View File
@@ -14,3 +14,16 @@ export function signalToCode(signal: NodeJS.Signals): number {
return 128;
}
}
export function codeToSignal(code: number): NodeJS.Signals {
switch (code) {
case 128 + 1:
return 'SIGHUP';
case 128 + 2:
return 'SIGINT';
case 128 + 15:
return 'SIGTERM';
default:
return 'SIGKILL';
}
}
+59
View File
@@ -0,0 +1,59 @@
import { signalToCode } from './exit-codes';
const exitEvents = [
'SIGINT',
'SIGTERM',
'SIGQUIT',
'SIGHUP',
'SIGKILL',
'exit',
] as const;
type ExitEvent = (typeof exitEvents)[number];
const signalHandlers: Partial<
Record<
ExitEvent,
Array<(signalOrCode: string | number) => void | Promise<void>>
>
> = {};
const registeredHandlers = new Set<string>();
export function registerExitHandler(
event: 'exit',
cb: (code: number) => any | Promise<any>
);
export function registerExitHandler<T extends Omit<ExitEvent, 'exit'>>(
event: T,
cb: (signal: T) => any | Promise<any>
);
export function registerExitHandler<T extends ExitEvent>(
event: T,
cb: (signalOrCode: T extends Omit<ExitEvent, 'exit'> ? T : number) => void
) {
signalHandlers[event] ??= [];
if (registeredHandlers.has(event)) {
return;
}
registerHandler(event);
}
function registerHandler(event: ExitEvent) {
registeredHandlers.add(event);
process.on(event, async (code?: number) => {
for (const cb of signalHandlers[event]) {
let next = cb(event === 'exit' ? code : event);
if (next instanceof Promise) {
await next;
}
}
if (event === 'exit') {
// process is already exiting, don't need to exit
} else {
process.exit(signalToCode(event));
}
});
}
for (const event of exitEvents) {
registerHandler(event);
}
@@ -127,7 +127,6 @@ async function buildHost(
}
});
process.on('SIGTERM', () => staticProcess.kill('SIGTERM'));
process.on('exit', () => staticProcess.kill('SIGTERM'));
});
}
@@ -160,9 +159,6 @@ function moveToTmpDirectory(
const cleanup = () => {
rmSync(commonOutputDirectory, { force: true, recursive: true });
};
process.on('SIGTERM', () => {
cleanup();
});
process.on('exit', () => {
cleanup();
});
@@ -210,7 +206,6 @@ export function startProxies(
const proxyServer = (sslCert ? https : http)
.createServer({ cert: sslCert, key: sslKey }, expressProxy)
.listen(staticRemotesConfig.config[app].port);
process.on('SIGTERM', () => proxyServer.close());
process.on('exit', () => proxyServer.close());
}
logger.info(`NX Static Producers (remotes) proxies started successfully`);
@@ -236,7 +231,6 @@ export function startProxies(
const proxyServer = (sslCert ? https : http)
.createServer({ cert: sslCert, key: sslKey }, expressProxy)
.listen(hostServeOptions.port);
process.on('SIGTERM', () => proxyServer.close());
process.on('exit', () => proxyServer.close());
logger.info('NX Static Consumer (host) proxy started successfully');
}
@@ -81,9 +81,6 @@ export default async function* serveExecutor(
}
};
process.on('exit', () => killServer());
process.on('SIGINT', () => killServer());
process.on('SIGTERM', () => killServer());
process.on('SIGHUP', () => killServer());
await waitForPortOpen(options.port);
@@ -127,7 +127,6 @@ async function buildHost(
}
});
process.on('SIGTERM', () => staticProcess.kill('SIGTERM'));
process.on('exit', () => staticProcess.kill('SIGTERM'));
});
}
@@ -160,9 +159,6 @@ function moveToTmpDirectory(
const cleanup = () => {
rmSync(commonOutputDirectory, { force: true, recursive: true });
};
process.on('SIGTERM', () => {
cleanup();
});
process.on('exit', () => {
cleanup();
});
@@ -214,7 +210,6 @@ export function startProxies(
const proxyServer = (sslCert ? https : http)
.createServer({ cert: sslCert, key: sslKey }, expressProxy)
.listen(staticRemotesConfig.config[app].port);
process.on('SIGTERM', () => proxyServer.close());
process.on('exit', () => proxyServer.close());
}
logger.info(`NX Static remotes proxies started successfully`);
@@ -240,7 +235,6 @@ export function startProxies(
const proxyServer = (sslCert ? https : http)
.createServer({ cert: sslCert, key: sslKey }, expressProxy)
.listen(hostServeOptions.port);
process.on('SIGTERM', () => proxyServer.close());
process.on('exit', () => proxyServer.close());
logger.info('NX Static host proxy started successfully');
}
@@ -129,8 +129,6 @@ function registerCleanupCallback(callback: () => void) {
process.off('exit', wrapped);
};
process.on('SIGINT', wrapped);
process.on('SIGTERM', wrapped);
process.on('exit', wrapped);
}
@@ -70,7 +70,6 @@ export function nxViteBuildCoordinationPlugin(
if (daemonClient.enabled()) {
unregisterFileWatcher = await createFileWatcher();
process.on('exit', () => unregisterFileWatcher());
process.on('SIGINT', () => process.exit());
} else {
output.warn({
title:
@@ -52,8 +52,6 @@ export async function* vitestExecutor(
};
if (watch) {
process.on('SIGINT', processExit);
process.on('SIGTERM', processExit);
process.on('exit', processExit);
}
@@ -250,7 +250,6 @@ export default async function* fileServerExecutor(
}
};
process.on('exit', processExitListener);
process.on('SIGTERM', processExitListener);
serve.stdout.on('data', (chunk) => {
if (chunk.toString().indexOf('GET') === -1) {