惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

U
Unit 42
C
Cybersecurity and Infrastructure Security Agency CISA
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
Know Your Adversary
Know Your Adversary
S
Securelist
I
Intezer
AWS News Blog
AWS News Blog
L
LINUX DO - 热门话题
P
Privacy International News Feed
Recent Announcements
Recent Announcements
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
博客园 - 聂微东
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
Attack and Defense Labs
Attack and Defense Labs
N
News and Events Feed by Topic
The GitHub Blog
The GitHub Blog
C
Cyber Attacks, Cyber Crime and Cyber Security
Schneier on Security
Schneier on Security
N
Netflix TechBlog - Medium
爱范儿
爱范儿
B
Blog
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
C
CERT Recently Published Vulnerability Notes
Hacker News: Ask HN
Hacker News: Ask HN
Google DeepMind News
Google DeepMind News
Engineering at Meta
Engineering at Meta
Blog — PlanetScale
Blog — PlanetScale
WordPress大学
WordPress大学
S
Secure Thoughts
K
Kaspersky official blog
N
News | PayPal Newsroom
O
OpenAI News
Last Week in AI
Last Week in AI
C
Check Point Blog
D
Darknet – Hacking Tools, Hacker News & Cyber Security
Cyberwarzone
Cyberwarzone
Application and Cybersecurity Blog
Application and Cybersecurity Blog
T
Tor Project blog
大猫的无限游戏
大猫的无限游戏
Vercel News
Vercel News
D
Docker
Hugging Face - Blog
Hugging Face - Blog
T
Threat Research - Cisco Blogs
Cisco Talos Blog
Cisco Talos Blog
The Register - Security
The Register - Security
博客园 - 司徒正美
Martin Fowler
Martin Fowler
人人都是产品经理
人人都是产品经理
P
Palo Alto Networks Blog

Rc-2020 on Julia Evans

Day 57: Trying to set up GitHub Actions Day 56: A little WebAssembly Day 53: a little nginx, IPv6, and wireguard Day 52: testing how many Firecracker VMs I can run Day 51: Fixed my logging and made a couple of puzzles Day 50: Building some tarballs for puzzles, and trying to make a kernel boot faster Day 49: making the VMs boot faster Day 48: Another Go program, and a little vim configuration Day 47: Using device mapper to manage Firecracker images Day 46: debugging an iptables problem Day 44: Building my VMs with Docker Day 43: Building VM images Day 42: Writing a Go program to manage Firecracker VMs Day 41: Trying to understand what a bridge is Day 40: screen flickering & a talk about containers Day 39: Customizing gotty's terminal Day 38: Modifying gotty to serve many different terminal applications at once Day 37: A new laptop and a little Vue Day 35: Launching my VMs more reliably Day 34: Learning about qemu Day 33: pairing is magic and beautiful git diffs Day 32: A Rails model that doesn't use the database with ActiveHash Day 24: a short talk about blogging myths, and a debugging tip Day 23: a little Rails testing Day 22: getting OAuth to work in Rails Day 19: Clustering faces (poorly) using an autoencoder Day 20: trying to figure out how Google Cloud IAM works Day 18: an answer to an autoencoder question Day 17: trying to wrap my head around autoencoders Day 13: BPTT, and debugging why a model isn't training is hard Day 11: learning about learning rates Day 10: Training an RNN to count to three Day 9: Generating a lot of nonsense with an RNN Day 8: Start with something that works Day 5: drawing lots of faces with sketch-rnn Day 3: an infinitely tall fridge Day 2: Rails associations & dragging divs around Day 1: a confusing Rails error message I'm doing another Recurse Center batch!
Day 21: wrangling systemd & setting up git deploys to a VM
Julia Evans · 2020-12-09 · via Rc-2020 on Julia Evans

On Monday I decided to take a break from machine learning, so I spent all day setting up a server for this incidents-as-a-service project I’m working on on digital ocean.

Here are a few things I learned:

digital ocean apps are compatible with Heroku

I was originally going to use GCP for this project, but I got mad because of my experience with IAM on Friday and decided to try Digital Ocean instead. It turns out that Digital Ocean is MUCH EASIER to use than GCP (at least at first) and so I decided to try it out.

One cool thing I found out is that Digital Ocean’s new “app platform” lets you deploy Heroku apps to it pretty seamlessly.

This ended up not working for me because I needed to SSH to other instances for my project and this doesn’t seem to be possible from a Digital Ocean “app” (which I guess is a container behind a pretty restrictive firewall).

So I decided to use a Digital Ocean VM instead.

digital ocean has nice VM images

My project is a Rails app. Digital Ocean seems to have a “marketplace” with a Ruby on Rails page, and so I clicked “Create Ruby on Rails droplet” and it created a VM for me that had:

  • nginx
  • Rails
  • Postgres
  • systemd services for all of those

all set up what seems to be a pretty reasonable way. I thought this was great and it seemed to be a pretty good starting point to set up a Rails app. I thought about using containers but I decided not to, maybe I’ll go back and make the whole thing more reproducible later.

I liked that there’s a Postgres already running on the machine, since it’s way cheaper than a managed Postgres. And I figure if I want to migrate to managed Postgres I can always do that later.

you can implement push-to-deploy with a git post-receive hook

Once I had that VM running, I was mad that I didn’t have the nice “push to deploy” experience that I got with Heroku / digital ocean apps, so I Googled other options.

I found this really nice blog post Deploying Code with a Git Hook on a DigitalOcean Droplet about how to use a git post-receive hook to deploy to a VM on push.

This approach feels more like “hacked together bash script” than “fancy stable system” but after spending some time wrangling systemd I got it to work and it’s kind of fun to have a more basic system where I push directly to the VM I’m running my code on.

systemd can run a script before your service starts

After I deploy my code with git push, I need to make sure to install new gems / run Rails migrations / etc.

There are lots of ways to do this, but I found out that you can set an ExecStartPre in systemd to run a script before the service starts. So if I run service rails restart, it’ll run my restart.sh script first and install any new required gems, etc.

My Rails systemd file’s Service section looks something like this:

[Service]
Type=simple
User=rails
Group=rails
WorkingDirectory=/my/rails/directory
ExecStart=/bin/bash -lc 'bundle exec puma'
Environment=RAILS_ENV=production
ExecStartPre=/bin/bash -x /path/to/my/restart/script
TimeoutSec=300s
RestartSec=300s
Restart=always

I needed to make TimeoutSec bigger because the restart script runs bundle install and sometimes that can take a while.

journald needed to be restarted for some reason

I spent a LOT of time being confused because systemd-journald didn’t have my Rails app’s logs, even though it seemed to be running correctly.

Eventually I restarted journald and it fixed everything, but I don’t really understand why. I really don’t understand systemd yet but maybe one day I’ll get there.

that’s all!

I found setting up a VM in a very non-reproducible way with a hacked together build/deploy system pretty fun. I might redo it to use containers/something that might be easier to maintain if the project ends up being something I want to keep.