The RailsNotes Newsletter 🟥 ISSUE #5

🟥 ISSUE #5 (Overmind, procfile, tmux, and debugger)

Your Procfile dutifully running your processes — “a document wired into a computer system with wires connecting it to glowing servers, isometric view, style of laurie greasley, studio ghibli, akira toriyama, james gilleard, watercolor“

— SPONSOR —

Namecheap is this week’s sponsor!

I use Namecheap for all my domain names (including railsnotes.xyz 😎). They’re great and I’ve always been happy with them.

These links are affiliate links 🤑, so if you buy something with them, you help support the RailsNotes newsletter.

ps. I just counted and somehow I own 12 domains via Namecheap… 🙉🙉🙉

Welcome to The RailsNotes Newsletter — Issue #5!

Thank you to all 382 of you for subscribing! 🎉🥳

Another week, more colossal growth! The RailsNotes community has doubled since I sent last week’s newsletter 📈. So, I just want to say a big hello to all the new people!

If you have any friends or co-workers that you think would enjoy my newsletter, please forward it to them! It would help me out heaps 😎

This issue is all about our dev environment — think bin/dev, Procfiles, foreman and overmind. As a software engineer myself, developer experience is super important to me — if you’re going to work on something, you want to enjoy it!

In fact, the thing that first pulled me to Ruby on Rails was one of its core principles — Optimize for programmer happiness. How could any sane developer argue against that?

FEATURED ARTICLE —

Would you trust this dude to run your Procfile? …well, better him than me I guess. Welcome to our new overlord 🪬.

This article will make you wish you’d heard of Overmind sooner (seriously).

If you’ve used foreman and bin/dev before, overmind is like them — it runs your Procfile. Except with overmind, it runs your Procfile really, really well.

Overmind uses tmux to run your processes in separate sessions, which lets you directly connect to them — super handy for debugging! This alone is a big improvement over bin/dev, which can’t do this easily.

But Overmind also supports tons of handy configurations, far beyond what foreman and bin/dev offer. For example, in this article, I show you a cool way to auto-run your database migrations with the OVERMIND_CAN_DIE flag. Don’t even think about trying that with foreman 🙅‍♂️.

You don’t want to miss this — check it out!

🌐 MORE ARTICLES —

This is another excellent Overmind article, and it’s also very recent! Nikola does a great job covering Overmind. He also sprinkles in some handy tmux tips along the way (which is great if you’re new to tmux). I think this article complements my Overmind article well, and if you have the time, I recommend you read both.

This article introduced Overmind (and its little sister, Hivemind) to the world. It includes some interesting history on the Procfile and foreman, and how they sowed the seeds for overmind. This article also has a short explanation of pseudo-terminals (which overmind makes use of), plus some interesting quotes from Sergey Alexandrovich, the creator of Overmind.

I couldn’t write about Overmind without including a tmux guide. To get the most out of Overmind, you’ll want to have, at least, a passing familiarity with tmux. If you’ve never used tmux before, that’s OK — this is a great beginner’s guide, which should walk you through everything you need to get started.

— ⚒️ HANDY TIP — 

→ Debug a process with overmind connect

I’m not sure this counts as a ‘handy tip’, but I wanted to show you how easy it is to attach Overmind to a debugger in your Rails apps. If you’ve ever tried to debug with debugger or pry alongside bin/dev and foreman, you’re going to love how simple this is.

If you have a web: process, and a Posts#index controller method like this —

#PostsController
def index
  @posts = Post.all
  debugger # start a debugger in our controller
end

You can attach to your debugger from your web: process by running overmind connect web, like this —

# attach to the debugger with overmind
overmind connect web

# now we're in the debugger, inside tmux
(rdbg) puts @posts

Once you’re done, you can detach from the tmux window with Ctrl+b d. How easy is that!