Meteor Deployment - how upgrade aplication



I use for deployment:
nginx as a reverse proxy web server which passes requests to our application;
pm2 – A production process manager that keeps an eye on our application, and restart it if it crashes

I implemented the applications on my own server, using the information contained under the link:

I want to ask how update the production version of the application ( adding more packages from the page and changing the code in the same application).

I replace application files and restarts pm2 job by running pm2 restart all
After launching the application I have a bug with server nginx “502 Bad Gateway”.

I would be grateful for any help or links to material that solve my problem.