Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pm2 config #9

Closed
wants to merge 2 commits into from
Closed

Conversation

riteshsp2000
Copy link
Member

Your checklist for this pull request

🚨Please review the guidelines for contributing to this
repository.

  • Make sure you are requesting to pull a topic/feature/bugfix branch
    (right side). Don't request your default branch!
  • Make sure you are making a pull request against the default branch
    (left side). Also you should start your branch off default branch.
  • Check the commit's or even all commits' message styles matches our
    requested structure.
  • Check your code additions will fail neither code linting checks nor unit
    test.
  • I have added necessary documentation (if appropriate)

Description

Configure pm2 for development and production.

Please describe your pull request.

❤️Thank you!

Post merge checklist

  • Follow steps from the guidelines for contributing to
    this repository.
  • If you are a new contributor, ping in the thread and one of the
    maintainers will add you to all-contributors list.

- run prettier script to format all the files

- run eslint script to fix linting errors
- setup scripts to initialize node app in development and production mode using pm2

- create pm2 config file (ecosystem.config.js)
@riteshsp2000 riteshsp2000 requested a review from abhibhaw July 2, 2021 12:08
@riteshsp2000 riteshsp2000 self-assigned this Jul 2, 2021
Copy link
Member

@abhibhaw abhibhaw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't we need to change the build commands in the workflows after this pm2 configuration?

@@ -0,0 +1,22 @@
module.exports = {
apps: [
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also we need 3 apps configurations, for staging, prod and PR

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes yes, I am working on this finding some suitable settings for the corresponding.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do you need three configs for PM2 ecosystem config? You can have same app config used in all three environments na?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have different env and app name for all 3. And that env's are subject to change during development time so was planning to have everything separate for now. Can keep one after the first production release.

@riteshsp2000
Copy link
Member Author

riteshsp2000 commented Jul 3, 2021

Don't we need to change the build commands in the workflows after this pm2 configuration?

Yes, we do need to update them, How about after this is all set up, you create a PR which would then set up the workflows for the remaining environments. I'll keep the original run/build commands as well so that this wont affect the current staging after merger.

@abhibhaw
Copy link
Member

abhibhaw commented Jul 3, 2021

Yo sounds great 🦾

@abhibhaw
Copy link
Member

abhibhaw commented Jul 3, 2021

You may need to change the app name as well, I am quite unsure about the spacing in the app name 🤔

@riteshsp2000
Copy link
Member Author

You may need to change the app name as well, I am quite unsure about the spacing in the app name 🤔

nah nah.... I'm pretty sure we can name with a space.

@riteshsp2000 riteshsp2000 linked an issue Jul 3, 2021 that may be closed by this pull request
@@ -0,0 +1,22 @@
module.exports = {
apps: [
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do you need three configs for PM2 ecosystem config? You can have same app config used in all three environments na?

"start:dev": "npx pm2 startOrGracefulReload ecosystem.config.js --env development",
"start:stage": "pm2 startOrGracefulReload ecosystem.config.js --env staging",
"start:prod": "pm2-runtime ecosystem.config.js --env production",
"stop": "npx pm2 stop ecosystem.config.js && npx pm2 delete ecosystem.config.js",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

calling a command stop and then deleting ain't good

Comment on lines +3 to +20
{
name: 'Aptiche Server',
script: './dist/index.js',
watch: false,
instances: 1, // TODO: change to max for production
exec_mode: 'cluster',
max_memmory_restart: '500M',
time: false,
error_file: './logs/pm2-err.log',
out_file: './logs/pm2-out.log',
log_file: './logs/pm2-app.log',
combine_logs: false,
kill_timeout: 2000,
min_uptime: '1m',
max_restarts: 5,
restart_delay: 1000,
autorrestart: true,
},
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is a thing known as an exponential back-off restart. Use that.

I see that is watch is false here, what do you plan for development phase?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Planning not to use pm2 during dev but will include this if you suggest.

@riteshsp2000 riteshsp2000 deleted the pm2-config branch August 30, 2021 13:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Setup PM2 for running node
3 participants