Gatsby: pm2 start with gatsby?

Created on 11 Jan 2019  路  3Comments  路  Source: gatsbyjs/gatsby

I'm trying to get auth0 demo of mine hosted on platform.sh, I keep on running into a 502 Bad gateway error on the callback.

Speaking with the support team at Platform.sh they are saying I need to start nodejs in my .platform.app.yaml script.

See documentation here - https://docs.platform.sh/languages/nodejs.html#configuration

What I've got so far.

name: app
type: "nodejs:10"

dependencies:
  nodejs:
    pm2: "^2.5.0"
    gatsby-cli: "^1.1.58"

disk: 2048

hooks:
  build: |
    npm install
    gatsby build

web:
  commands:
    start: "PM2_HOME=/app/run pm2 start gatsby -- serve-build --no-daemon"
  locations:
    '/':
      root: 'public'
      index: [ 'index.html' ]

I managed to get something together on pm2 from this post here - https://github.com/gatsbyjs/gatsby/issues/604#issuecomment-274650074

I think the magic script is below, but I'm not sure? Anyone have any thoughts.

web:
  commands:
    start: "PM2_HOME=/app/run pm2 start gatsby -- serve-build  --no-daemon"
question or discussion

Most helpful comment

Looks good. Noticed that gatsby-cli is v1. If you're, using v2 gatsby -- serve-build becomes gatsby -- serve.

Also on a side note, since the output from Gatsby are all static assets you probably don't need the Node server and can get serve them straight off a CDN. Check out Netlify if you're interested in this approach.

All 3 comments

Looks good. Noticed that gatsby-cli is v1. If you're, using v2 gatsby -- serve-build becomes gatsby -- serve.

Also on a side note, since the output from Gatsby are all static assets you probably don't need the Node server and can get serve them straight off a CDN. Check out Netlify if you're interested in this approach.

Thanks @sidharthachatterjee

I did think that, but they have told me differently.

Anyways I'll give it a go - thanks again :)

You're very welcome, @imshuffling 馃檪

Closing this for the moment, please feel free to reopen if you see any issues with this!

Was this page helpful?
0 / 5 - 0 ratings