Node.js Server-Side Environment#
CodeRed Cloud provides a bare-bones Node.js environment based on Debian, with corepack enabled.
Server Entrypoint: cr-run.sh
#
The entrypoint, or main process, of your Node.js app is always cr-run.sh
. This file is required for the server to start. If this file is missing, a default boilerplate app will be loaded instead.
Most likely, this will contain a single command as so:
#!/bin/sh
exec node --v8-pool-size=${WORKERS} app.js
Environment Variables#
The following environment variables are automatically configured:
CR_ENV
=prod
in the production environment andstaging
in the staging environment.
NODE_ENV
is always set toproduction
.
VIRTUAL_HOST
is the primary domain name your website is running under. This is preferable to hard-coding domains.
WORKERS
is the recommended number of worker processes based on the amount of resources allocated to your CodeRed Cloud plan. This is useful when using a server such as PM2 or using Node.js worker threads.
Custom environment variables can be set via the CodeRed Cloud dashboard under Website > Deployment > Environment Variables. These are stored encrypted in a keyvault, and are automatically decrypted and loaded into the server at runtime.
Logging#
By default, no logging is enabled. However, you can safetly log to the /log/
directory (also symlinked in /var/log
).
For details see Logging on CodeRed Cloud.