Skip to content

How to deploy with PM2? #380

Closed
Closed

Description

@louisscruz

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?

Activity

  1. moderndegree commented on Mar 4, 2016

    @moderndegree

    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.

  2. louisscruz commented on Mar 4, 2016

    @louisscruz
    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!

  3. PatrickJS commented on Mar 9, 2016

    @PatrickJS
    Owner
  4. louisscruz commented on Mar 9, 2016

    @louisscruz
    Author

    @gdi2290 Done!

  5. PatrickJS commented on Mar 9, 2016

    @PatrickJS
    Owner
  6. joshwiens commented on Oct 27, 2016

    @joshwiens
    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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions