Code Monkey home page Code Monkey logo

Comments (3)

9gaurav avatar 9gaurav commented on June 2, 2024

I just deployed on DigitalOcean droplet and this worked.
I reckon it should work for EC2 as well.

start:prod script under packages.json gave me some clues
"start:prod" : "cross-env NODE_ENV=production node index.js"
According to this we need to set environment as production and then run index.js

pm2 config and setup

Step 1:
cd to project folder

Step 2: Create ecosystem.config.js file for pm2
with the following config

module.exports = {
  apps : [{
    name      : 'MERN',
    script    : 'index.js',
    env: {
      NODE_ENV: 'development'
    },
    env_production : {
      NODE_ENV: 'production'
    }
  }],
};

Replace 'MERN' with your app's name so it will show in pm2 list.

Step 3: Start app's process using pm2

For production -
pm2 start --env production
For development -
pm2 start --env development

You should see following output

 App name │ id │ mode │ pid   │ status │ restart │ uptime │ cpu  │ mem       │ user │ watching │
├──────────┼────┼──────┼───────┼────────┼─────────┼────────┼──────┼───────────┼──────┼──────────┤
│ MERN     │ 0  │ fork │ 29305 │ online │ 0       │ 3m     │ 0.1% │ 93.4 MB   │ root │ disabled │

Thats it! 👍 Your app is now up and running.
Hope this helps!
Please let me know how it goes.

Some basic pm2 operations / [ replace MERN with your app name]

Stop App
pm2 stop MERN

Start App
pm2 start MERN

Monitor App
pm2 monit MERN

Delete App
pm2 delete MERN

Show list of running pm2 processes
pm2 list

from mern-starter.

sn17091004 avatar sn17091004 commented on June 2, 2024

Hi,

Thanks for the response. Let me spin up an instance with all these changes and I will update if it worked. Once again, thanks.

from mern-starter.

mannyhenri avatar mannyhenri commented on June 2, 2024

Will close for the time being, feel free to reopen if there is still an issue related to the repo itself.

from mern-starter.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.