-
Notifications
You must be signed in to change notification settings - Fork 1k
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
Adds baremetal deploy strategy #4750
Conversation
🤘 |
This will need to be added to deploy CI over here as well: |
Are we gonna run a persistent server somewhere forever to support that? Or we just mark it as experimental and anything goes. ;) |
@cannikin Does PM2 support any notifications about deploy status? E.g. if you trigger a deploy and something fails, how do you know? |
You'll see the error message in the console! For some of them at least...I don't know every error that pm2 could throw, but these common ones on startup/restart show nicely: I'm not sure what happens if the process itself errors out though...I don't think pm2 itself even shows that in the console, it gets ported to the log output for that process... |
Ok, got it. When added to the Deploy CI repo, I'll need to create a GH Workflow to deploy and can handle notification via the workflow success/fail accordingly. ✅ |
Do you just look for text in the output? If it's the kind of error I can catch it'll always start with that "Deploy failed!" message... |
Ah, I just saw the error exit 1, which will cause the GH Workflow to fail. That's all I need! |
I think it's working! Lemmie write up the instructions for getting a server setup and then you should be able to add to the deploy suite! |
…to rc-baremetal-deploy
… pm2 process names Look for exit code and if it's not 0, dump the output from stderr and exit(1) ourselves
✔️ Deploy Preview for redwoodjs-docs canceled. 🔨 Explore the source changes: cba2729 🔍 Inspect the deploy log: https://app.netlify.com/sites/redwoodjs-docs/deploys/6232d02e969f7400086d5a76 |
To quote Alain de Lille, the French theologian and poet: "All roads lead to AWS." I've tried several different hosting providers and in the end, I ended back where I always do: deploying to EC2 servers on AWS. But right now you'd need to roll your own deployment setup. This PR intends to change that.
Redwood has the ability to serve both the web and api sides for production via
yarn rw serve
. In my case I've been serving the web side with nginx for maximum performance, and serving the api side via our built-inyarn rw serve api
command, monitored by pm2. pm2 handles clustering the node processes across all available CPUs for maximum performance.It's been great to see consistent GraphQL calls roundtrip in <50ms, compared to serverless environments where the cold-boot time alone can be 1000ms, and even a warmed-up endpoint takes >200ms returning minimal data.
Not to mention the other benefits that come with being able to
ssh
into your hardware and make changes (some would consider having to do this at all to be a drawback!). I'm also able to configurepm2
as a periodic background job processor. I'll include instructions for doing this in the docs.Closes #4217
Setup / Testing Instructions
Until I get a doc together, here's how to do this:
Prerequisites
Start a server somewhere and note the hostname and user. I worked on an Ubuntu 20.04 (amd64) t2.small instance when developing this deploy strategy. Be sure that any attached security group allows access to port 22 from your home IP, as well as ports 8910 and 8911 open to at least your home IP, or 0.0.0.0 if you want it accessible from anywhere.
You can just commit the SQLite database to the codebase (remove the
dev.db*
entry from.gitignore
) and not worry about configuring a remote DB instance somewhere.Local Machine
yarn -W -D add pm2
(an optional global install ofpm2
would be nice, but that'll have to happen in a future release)mydomain.com:8911
)yarn rw setup deploy baremetal
deploy.toml
: set server host, user, path. If you setup agent forwarding above, leaveagentForward: true
, otherwise removeServer
~/.ssh/authorized_keys
for easy login, otherwise addprivateKey: /path/to/private.pem
todeploy.toml
orpassword: [password]
if you don't want to use keyssudo apt-get update && sudo apt-get upgrade -y
~/.bashrc
and comment out code block at top starting with# If not running interactively, don't do anything
curl https://raw.githubusercontent.com/creationix/nvm/master/install.sh | bash
nvm install 16
npm install -g yarn
/var/www/myapp
)git clone
repo into deploy directoryyarn install
nowLocally
yarn rw deploy baremetal --first-run
http://server.com:8910
On future deploys just
yarn rw deploy baremetal
and it'll restart processes instead of starting them.This should make the site available at port 8910 just like our default config. I'll have details in the docs for serving on port 80 (but ideally you want this behind a real webserver like nginx). This isn't the ideal deploy setup (not secure, CORS, one single
serve
process running) so the docs will go into installing nginx and having your web side served from there, only runyarn rw serve api
and setup the proxy through nginx, removing CORS, etc. This is how https://app.algostake.org is configured!