From b983d1fcf0b27c9f645115dcbcec2f2c47b5aeaa Mon Sep 17 00:00:00 2001 From: Nico <64479393+the-other-dev@users.noreply.github.com> Date: Wed, 10 Apr 2024 17:01:45 +0200 Subject: [PATCH] Add env variables to configure PM2 log paths + documentation (#22155) * Add env variables to configure PM2 log paths + documentation * Sign Contributor License Agreement * Run prettier fix * Add changeset --------- Co-authored-by: Rijk van Zanten --- .changeset/lazy-bears-tan.md | 5 +++++ contributors.yml | 1 + docs/self-hosted/config-options.md | 24 +++++++++++++----------- ecosystem.config.cjs | 4 ++++ 4 files changed, 23 insertions(+), 11 deletions(-) create mode 100644 .changeset/lazy-bears-tan.md diff --git a/.changeset/lazy-bears-tan.md b/.changeset/lazy-bears-tan.md new file mode 100644 index 0000000000..bf7c2f8fff --- /dev/null +++ b/.changeset/lazy-bears-tan.md @@ -0,0 +1,5 @@ +--- +'docs': patch +--- + +Added support to for configuring PM2_LOG_ERROR_FILE and PM2_LOG_OUT_FILE diff --git a/contributors.yml b/contributors.yml index 880ad04f6f..9a45f1855a 100644 --- a/contributors.yml +++ b/contributors.yml @@ -123,3 +123,4 @@ - useEffects - jonaskohl - kimiaabt +- the-other-dev diff --git a/docs/self-hosted/config-options.md b/docs/self-hosted/config-options.md index 75f8a175f7..d8ce11707d 100644 --- a/docs/self-hosted/config-options.md +++ b/docs/self-hosted/config-options.md @@ -1089,16 +1089,18 @@ These environment variables only exist when you're using the official Docker Con For more information on what these options do, please refer to [the `pm2` documentation](https://pm2.keymetrics.io/docs/usage/application-declaration/). -| Variable | Description | Default | -| ----------------------------- | ------------------------------------------------------------------ | ----------- | -| `PM2_INSTANCES`[1] | Number of app instance to be launched | `1` | -| `PM2_EXEC_MODE` | One of `fork`, `cluster` | `'cluster'` | -| `PM2_MAX_MEMORY_RESTART` | App will be restarted if it exceeds the amount of memory specified | — | -| `PM2_MIN_UPTIME` | Min uptime of the app to be considered started | — | -| `PM2_LISTEN_TIMEOUT` | Time in ms before forcing a reload if app not listening | — | -| `PM2_KILL_TIMEOUT` | Time in milliseconds before sending a final SIGKILL | — | -| `PM2_MAX_RESTARTS` | Number of failed restarts before the process is killed | — | -| `PM2_RESTART_DELAY` | Time to wait before restarting a crashed app | `0` | -| `PM2_AUTO_RESTART` | Automatically restart Directus if it crashes unexpectedly | `false` | +| Variable | Description | Default | +| ----------------------------- | ------------------------------------------------------------------ | -------------------------------------------- | +| `PM2_INSTANCES`[1] | Number of app instance to be launched | `1` | +| `PM2_EXEC_MODE` | One of `fork`, `cluster` | `'cluster'` | +| `PM2_MAX_MEMORY_RESTART` | App will be restarted if it exceeds the amount of memory specified | — | +| `PM2_MIN_UPTIME` | Min uptime of the app to be considered started | — | +| `PM2_LISTEN_TIMEOUT` | Time in ms before forcing a reload if app not listening | — | +| `PM2_KILL_TIMEOUT` | Time in milliseconds before sending a final SIGKILL | — | +| `PM2_MAX_RESTARTS` | Number of failed restarts before the process is killed | — | +| `PM2_RESTART_DELAY` | Time to wait before restarting a crashed app | `0` | +| `PM2_AUTO_RESTART` | Automatically restart Directus if it crashes unexpectedly | `false` | +| `PM2_LOG_ERROR_FILE` | Error file path | `$HOME/.pm2/logs/-error-.log` | +| `PM2_LOG_OUT_FILE` | Output file path | `$HOME/.pm2/logs/-out-.log` | [1] [Redis](#redis) is required in case of multiple instances. diff --git a/ecosystem.config.cjs b/ecosystem.config.cjs index 59430610e5..5218fda853 100644 --- a/ecosystem.config.cjs +++ b/ecosystem.config.cjs @@ -24,5 +24,9 @@ module.exports = [ max_restarts: process.env.PM2_MAX_RESTARTS, restart_delay: process.env.PM2_RESTART_DELAY ?? 0, autorestart: process.env.PM2_AUTO_RESTART === 'true', + + // Logs + error_file: process.env.PM2_LOG_ERROR_FILE, + out_file: process.env.PM2_LOG_OUT_FILE, }, ];