I have created an AdonisJS application from scratch, no custom code at the moment. I compile it and then try to serve it with pm2
, but when I do pm2 logs web-app
I get the following error:
Missing environment variable "DB_DATABASE"
I tried to add it to my ecosystem.config.cjs
file like that:
module.exports = {
apps : [{
name: 'web-app',
script: 'build/bin/server.js',
instances: 2,
exec_mode: 'cluster',
autorestart: true,
env: {
DB_DATABASE: 'my_database_name',
}
}]
};
and it actually removes this error (now I get Missing environment variable "DB_USER"
, but I guess it means I need to copy all environment variables).
It doesn’t comply with avoid duplicated code practice, even worse it means I define same variable in two places.
Is there any other way to solve this error?