Why does pm2 start my ghost blog in developement?

692 views Asked by At

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" } } ] }

2

There are 2 answers

0
Oleg Konovalenko On BEST ANSWER

Because ghost blog always runs in development mode by default. If you want to run it with pm2 in production use following command

NODE_ENV=production pm2 start index.js

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.

1
Shubham SHARMA On

Have you tried to create an ecosystem file to declare how you want to launch in production ? http://pm2.keymetrics.io/docs/usage/application-declaration/

If yes can you show it ?