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

How to deploy with PM2? #380

Closed
louisscruz opened this issue Mar 3, 2016 · 6 comments
Closed

How to deploy with PM2? #380

louisscruz opened this issue Mar 3, 2016 · 6 comments

Comments

@louisscruz
Copy link

Running npm run server:prod is working on my server. However, when I try to use PM2 through pm2 start dist, there's a list of errors in the logs:

PM2: 2016-03-03 16:59:10: Script /opt/dailydownbeat/dist had too many unstable restarts (15). Stopped. "errored"

PM2: 2016-03-03 16:59:10: Script /opt/testproject/dist had too many unstable restarts (15). Stopped. "errored"

dist-0 (err):     at Function.Module._load (module.js:290:25)
dist-0 (err):     at Function._load (/usr/local/lib/node_modules/pm2/node_modules/pmx/lib/transaction.js:62:21)
dist-0 (err):     at Object.<anonymous> (/usr/local/lib/node_modules/pm2/lib/ProcessContainerFork.js:36:21)
dist-0 (err):     at Module._compile (module.js:413:34)
dist-0 (err):     at Object.Module._extensions..js (module.js:422:10)
dist-0 (err):     at Module.load (module.js:357:32)
dist-0 (err):     at Function.Module._load (module.js:314:12)
dist-0 (err):     at Function.Module.runMain (module.js:447:10)
dist-0 (err):     at startup (node.js:140:18)
dist-0 (err): Error: Cannot find module '/opt/testproject/dist'
dist-0 (err):     at Function.Module._resolveFilename (module.js:339:15)
dist-0 (err):     at Function.Module._load (module.js:290:25)
dist-0 (err):     at Function._load (/usr/local/lib/node_modules/pm2/node_modules/pmx/lib/transaction.js:62:21)
dist-0 (err):     at Object.<anonymous> (/usr/local/lib/node_modules/pm2/lib/ProcessContainerFork.js:36:21)
dist-0 (err):     at Module._compile (module.js:413:34)
dist-0 (err):     at Object.Module._extensions..js (module.js:422:10)
dist-0 (err):     at Module.load (module.js:357:32)
dist-0 (err):     at Function.Module._load (module.js:314:12)
dist-0 (err):     at Function.Module.runMain (module.js:447:10)
dist-0 (err):     at startup (node.js:140:18)

Before I submit an issue with the PM2 people, can you verify that this should work? Do I need to configure something in the project to make this work?

@moderndegree
Copy link

This project doesn't appear to provide an app server. You will need to create an Express (or similar) server to point pm2 at. Ideally, you should be pushing the contents of dist to a CDN and having your app server run separately.

@louisscruz
Copy link
Author

In case it helps anyone, I found a way to have pm2 serve the dist folder. This is more or less the setup. Then, I've weaseled nginx into picking up the appropriate port for non-backend requests. Hope this can help someone!

@PatrickJS
Copy link
Owner

@louisscruz
Copy link
Author

@gdi2290 Done!

@PatrickJS
Copy link
Owner

@joshwiens
Copy link
Contributor

Resolving - resolution exists in wiki article

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

No branches or pull requests

4 participants