From 34c393408d1c506546337f662dcbae20de2de451 Mon Sep 17 00:00:00 2001 From: Andrew Ovens <andrew.ovens@quantifi.ca> Date: Fri, 16 Jun 2023 09:18:41 -0600 Subject: [PATCH] feat(core): Allow specifying daemon socket dir Setting NX_DAEMON_SOCKET_DIR will place the daemon socket in the specified directory --- docs/shared/daemon.md | 5 +++++ packages/nx/src/daemon/tmp-dir.ts | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/docs/shared/daemon.md b/docs/shared/daemon.md index 6a348395c8fbe..5a1bdae8e5f2a 100644 --- a/docs/shared/daemon.md +++ b/docs/shared/daemon.md @@ -36,3 +36,8 @@ When using Nx in a CI environment, the Nx Daemon is disabled by default. Whether ## Logs To see information about the running Nx Daemon (such as its background process ID and log output file), run `nx daemon`. Once you have the path to that log file, you could either open it in your IDE or stream updates in a separate terminal window by running `tail -f {REPLACE_WITH_LOG_PATH}`, for example. + +## Customizing the socket location + +The Nx Daemon uses a unix socket to communicate between the daemon and the Nx processes. By default this socket gets placed in a temp directory. If you are using Nx in a docker-compose environment, however, you may want to run the daemon manually +and control its location to enable sharing the daemon among your docker containers. To do so, simply set the NX_DAEMON_SOCKET_DIR environment variable to a shared directory. diff --git a/packages/nx/src/daemon/tmp-dir.ts b/packages/nx/src/daemon/tmp-dir.ts index 459b2fa4ff258..96fa74215c9af 100644 --- a/packages/nx/src/daemon/tmp-dir.ts +++ b/packages/nx/src/daemon/tmp-dir.ts @@ -21,7 +21,7 @@ export const DAEMON_OUTPUT_LOG_FILE = join( 'daemon.log' ); -const socketDir = createSocketDir(); +const socketDir = process.env.NX_DAEMON_SOCKET_DIR || createSocketDir(); export const DAEMON_SOCKET_PATH = join( socketDir,