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 <rijkvanzanten@me.com>
This commit is contained in:
Nico
2024-04-10 17:01:45 +02:00
committed by GitHub
parent bf9b95a5c3
commit b983d1fcf0
4 changed files with 23 additions and 11 deletions

View File

@@ -0,0 +1,5 @@
---
'docs': patch
---
Added support to for configuring PM2_LOG_ERROR_FILE and PM2_LOG_OUT_FILE

View File

@@ -123,3 +123,4 @@
- useEffects
- jonaskohl
- kimiaabt
- the-other-dev

View File

@@ -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`<sup>[1]</sup> | 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`<sup>[1]</sup> | 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/<app name>-error-<pid>.log` |
| `PM2_LOG_OUT_FILE` | Output file path | `$HOME/.pm2/logs/<app name>-out-<pid>.log` |
<sup>[1]</sup> [Redis](#redis) is required in case of multiple instances.

View File

@@ -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,
},
];