redwood: Baremetal deploy fails on Starting serve serve process step - pm2

I am happy to do additional testing and contribute patches, etc to help solve this issue.

Main issue

  • What happens
    • I have run yarn rw setup deploy baremetal and made the necessary config settings (below)
    • When i run yarn rw deploy baremetal --firstrun all steps succeed until i get to “Starting serve process ofr the first time”. At that step i get an error that the Deploy Failed running the command yarn pm2 start ecosystem.config.js --only serve
    • If i ssh into the server i can manually start the service using the “manual” pm2 command of pm2 start ecosystem.config.js
  • What is expected
    • I am expecting that this step should be running pm2 start ecosystem.config.js to install the initial api services. I cannot find a reference to using yarn to run the pm2 command. I suspect i am missing something in my packages config possibly?

Additional thoughts

  • I found it necessary to run pm2 save to make my settings persist, this would be helpful to add
  • possibly a statement about pm2 startup to discuss injecting pm2 into the systems normal services so it will run on reboot

Relevant configs

deploy.toml
[[servers]]
host = "redwood"
username = "zach"
agentForward = false
privateKey = "/Users/zachpeters/.ssh/id_rsa"
migrate = false
sides = ["api","web"]
path = "/var/www/oblique-strategies"
processNames = ["serve"]
package.json (root)
{
  "private": true,
  "workspaces": {
    "packages": [
      "api",
      "web",
      "packages/*"
    ]
  },
  "devDependencies": {
    "@redwoodjs/core": "^1.0.0",
    "node-ssh": "^12.0.4"
  },
  "eslintConfig": {
    "extends": "@redwoodjs/eslint-config",
    "root": true
  },
  "engines": {
    "node": ">=14.19 <=16.x",
    "yarn": ">=1.15"
  },
  "prisma": {
    "seed": "yarn rw exec seed"
  },
  "packageManager": "yarn@3.2.0"
}
ecosystem.config.js
module.exports = {
  apps: [
    {
      name: 'api',
      script: 'node_modules/.bin/rw',
      args: 'serve api',
      instances: 'max',
      exec_mode: 'cluster',
      wait_ready: false,
      listen_timeout: 10000,
    },
  ],
}

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 16 (15 by maintainers)

Most upvoted comments

Hello! You shouldn’t need to add pm2 to package.json, it really needs to be installed globally on the server, not in your app:

yarn global add pm2
# or
npm install -g pm2

We usually prefer to do help like this in the Discord!

#5139 merged - adds “save” step to baremetal and add docs for baremetal startup

continuing on local/global pm2 options