Problems during baremetal deploy

Hey guys. First of all, I must say that I am loving the framework.

I was following the tutorial in the docs, then, I wanted to test if I could deploy the project to a vps on digital ocean, so, I started to follow the baremetal deploy guide in the docs, but I got some problems in the process.

First, when I tried to run “yarn rw deploy baremetal --first-run”, It got stuck in the “Building web” step. In the VPS, it got jammed there. Then, in the next attempts, it just quits the script execution without any feedback:

Running locally it failed, but did not returned any error:

Then, I tried to execute manually the command “yarn rw build web” (running locally):

When I try to run in the vps:

Going forward, then when I try to execute “yarn pm2 start [service]” (running locally):

I am doing something wrong? I believe I’ve followed all steps listed in the documentation, but I don’t know if I am missing something.

By the way, the code I am trying to deploy, if someone wanna give a look (this is just the guide code, with a docker-compose file for the postgresql database. About the database, It was running before I tried the deploy script):

Howdy! My guess is that the DO instance can’t handle building the web side, and it just be killing the execution of the script without any error message. How much RAM in on that instance? In my experience you need at least 1GB to get the web side to build. When you ran yarn rw build web on the server, it looks like it just gave up and dumped you back to the prompt with no error message? That’s why you’re seeing what you’re seeing in the baremetal error output (an empty box).

You’ll need to install pm2 before you can use it to monitor anything. yarn add -WD pm2

However, I’ve got a PR in the works that’s going to change how a chunk of the baremetal deploy works (including requiring a global install of pm2), you may want to wait for that to get released! Updates Baremetal deploy to use `git clone` and branch names by cannikin · Pull Request #5282 · redwoodjs/redwood · GitHub

1 Like

Hey @rob!

Thanks a lot for the reply and for the work on this awesome project. I believe you are correct, I got the smaller DO droplet instance possible to test It. I will try again on another one with more memory and I will post here the outcome.

About the part that the command “yarn rw deploy baremetal --first-run” failed (returning with a empty red box), I was running it locally on my development machine, and I believe it was not a RAM issue (but running the command “yarn rw build web” did the job), so I still don’t understand why it failed, but I will try again.

About the pm2 issue, thanks for the information. I believe I got confused with the fact that Redwood was taking care of everything and forgot that I had to install it globally first.

Yeah you’ll be able to run yarn rw build web on your development machine all day and it’ll be fine, you probably have 8 or 16GB of RAM I’m guessing?

For pm2 it’s confusing: using the current release of baremetal, you’ll need to install pm2 locally in your app (yarn add -WD pm2). And then pm2 runs on the server (the example code you had above made it look like you were trying to start it on your dev machine, but that’s incorrect!). You can test it on the server by running something like yarn pm2 status or yarn pm2 start ecosystem.config.js from within the app directory.

The next release of baremetal (which may not be the next release of Redwood, we haven’t decided yet), you’ll need to install it globally (yarn global add pm2).

1 Like

Thanks again for the help, Rob!

Yes, now that you explained the steps, is indeed kinda confusing heheh.

When I tried to install the pm2 locally with yarn add -WD pm2 I got the error below, saying that the options passed are not valid:

I am still getting a empty red box as feedback, but now I know the error is the pm2 thing.

I’ve tried to install pm2 globally with npm on the VPS and tried to run the yarn rw deploy baremetal --first-run command, but it did not worked too:

Then, I tried to install the pm2 using just yarn add pm2 (in the VPS that I am trying to deploy to) and then I tried to run yarn rw deploy baremetal --first-run and:

It seems it worked. No idea why, but I will take that win for now and proceed to the next steps to finish the deploy configs.

To give a little more of context, the machine I am trying to deploy to is a Ubuntu 20.

Going forward in the tutorial, I did the pm2 step, and then I tried to run again the yarn rw deploy baremetal:

Trying to run the commands individually:

When I check the logs to discover why they are crashing:

Error: Cannot find module '/var/www/app/redwoodblog/api'

Error: Cannot find module '/var/www/app/redwoodblog/web'

But I have both directories:

image

Maybe is my config files?

deploy.toml:

[[servers]]
host = "leieordem.net"
username = "jc"
agentForward = true
sides = ["api","web"]
path = "/var/www/app/redwoodblog"
processNames = ["serve"]

ecosystem.config.js:

module.exports = {
  apps: [
    {
      name: 'api',
      script: 'node_modules/.bin/rw',
      args: 'serve api',
      instances: 'max',
      exec_mode: 'cluster',
      wait_ready: true,
      listen_timeout: 10000,
    },
  ],
}

In the ecosystem.config.js I have only the api side because I was following the recommendation in the docs, to serve the web side from nginx (Introduction to Baremetal | RedwoodJS Docs).

Maybe I am doing something wrong?

By the way, if I can help with anything (I believe that I could help with the documentation or something), let me know, would be a pleasure to help!

The “process or namespace serve not found” sounds like you don’t have a process named “serve” in ecosystem.config.js any more. If you change the name there you need to change it in the processNames var of deploy.toml as well. I can see in your following screenshots that you have processes called api and web so I’m guessing that’s what’s going on.

Not sure what’s going on with that “module” error…where are you running the yarn pm2 commands from?

I’ve got a bunch of PRs coming for baremetal that will require a different file structure on the server, you might want to wait for those to be released (within the next couple of weeks) before spending too much more time on this current configuration!