I am not able to understand why pm2 starts my ghost blog in developement instead of production.
I can run this
npm start --production
and everything is fine like I want it. But if I try to use pm2
pm2 start index.js
it starts my blog in developement which I don't want to. I must be blind but can not see in the docs how I can force pm2 to start in production mode.
I only have success starting the app with npm like this:
npm start --production
I tried with a config file ecosystem.config.js
and to start it like this:
pm2 start ecosystem.config.js
or
pm2 start ecosystem.config.js --env production
but it seems to start in developement. Here is my config file.
module.exports = {
apps : [
{
name : "asle",
script : "index.js",
env: {
COMMON_VARIABLE: "true"
},
env_production : {
NODE_ENV: "production"
}
}
]
}
Because ghost blog always runs in development mode by default. If you want to run it with pm2 in production use following command
You can also read in my blog post: https://drifts.io/how-to-setup-ghost-blog-on-vps/#step5installpm2processmanager
Also dont forget to use pm2 startup and save to make sure it persistent over reboots.