Commit graph

18 commits

Author SHA1 Message Date
792da067e3 Add monit watching for nginx and pm2
When I woke up this morning, the app had crashed because the mysql connection was closed!

I'm not sure, why that caused a _crash_? Or why pm2 didn't pick up on it, and said the process was still online? (Maybe the process was running, but the server had stopped?) Those could be good to investigate?…

…but better than diving too far into the details, is to just address the high-level problem: if the app goes down for unexpected reasons, I want it back up!! lol

In this change, we add `monit`, a solid system for monitoring processes (including checking for behavior, like responding to net requests), and configure it to watch the app process and the nginx process.

To test, you can run `pm2 stop impress-2020`, or `systemctl stop nginx`, to see that Monit brings them back up within seconds!

This does add some potential surprise if you're _trying_ to take the processes down. The easiest way is to send the stop command through monit, like `monit stop nginx`. This will disable monitoring until you start it again through monit, I think? (You can also disable/enable monitoring as a direct command, regardless of app state.)
2021-11-03 16:32:14 -07:00
2f874653bf Update pm2 tasks to update the config correctly
Previously, if you changed the pm2 ecosystem file content, it wouldn't actually be reflected in the running services. Now it will be!
2021-11-03 15:43:37 -07:00
7131bc0ea9 Set up certbot during setup playbook
You can see how, instead of the default experience where certbot edits your config for you, I've referenced the certificates in the config in the first place, and set up certbot to just generate them!

Also, I learned about certbot non-interactive mode! At first I wrote this with the Ansible `expect` module lol :p
2021-11-03 01:00:28 -07:00
9a4b905639 Set up basic nginx in front of impress-2020
It loads kinda! auth0 is crashing us because it refuses to run over http:// but hey! That's pretty cool!
2021-11-03 00:07:30 -07:00
4f372af132 Optimization: Reuse node_modules when possible
`yarn install` is slow, I'd like to skip it! Vercel and other hosts do a similar cheat here.
2021-11-02 23:56:50 -07:00
27b9f50afb Oops, Next.js builds are in .next/, not in build/
I was copying over an old create-react-app build folder, and the app was crashing remotely because there was no build!

Anyway woo it looks like the app is at least running now, `curl localhost:3000` shows results! >:3
2021-11-02 23:02:22 -07:00
9d41e80942 Use pm2 to run the deployed app 2021-11-02 22:49:45 -07:00
056c03fb42 Create a current version symlink
This is mostly just for convenience!
2021-11-02 21:53:20 -07:00
49cc2224b6 Refactor out a remote_versions_root variable 2021-11-02 21:29:14 -07:00
c13114b0cc Fix old version cleanup to sort by modified date
I was sorting by version name, which _was_ reliable until I changed my version name format, and then a deploy cleaned up the version it had just deployed because it no longer sorted to the end!

Rather than be dependent on a stable version name format, and set myself up for more surprises, I'm going to instead use the folder's modified time. While there could be surprising ways for folder timestamps to be updated, I expect it to be _more_ reliable overall.
2021-11-02 21:16:46 -07:00
bddcf91c02 Add more details to deploy README 2021-11-02 21:14:54 -07:00
a3859b36bf Safer deploy version names
Huh, I was previously using ISO timestamps, but it turns out Yarn doesn't handle binary paths very reliably when your folder names contain colons 😳 so `canvas` was failing with `node-gyp not found`

I've documented it here in this self-answered StackOverflow question, so hopefully the next future person searching will find my answer! https://stackoverflow.com/q/69819597/107415
2021-11-02 21:14:47 -07:00
fb5b0fe611 Add task to clean up older deployed versions 2021-11-02 19:02:36 -07:00
edd983c97a Refactor deploy to build locally, not remotely 2021-11-02 18:47:13 -07:00
d17c4cea8b Add yarn build to deploy playbook
also secret copying, which was required for the cached-data step
2021-11-02 16:45:07 -07:00
dde8cee1e3 Add deploy playbook: pulls git and installs deps 2021-11-02 16:36:39 -07:00
537aeb4118 Ansible tasks to set up web user, install Node 2021-11-02 16:01:30 -07:00
a915bc4b49 Start of an Ansible playbook
Yep yep, we're getting deploy tasks set up! :3
2021-11-02 14:45:05 -07:00