Urgent.News

One page, thousands of outlets. See who else covered it.

Editions

Tech

Building Distributed Systems in Elixir: Part 5 — Supervisor From Scratch

In the previous part of this series, we explored process links. A linked worker that crashes sends an exit signal to the process linked to it. By default, that failure propagates and can terminate both processes. We also saw that a process can trap exits: Process . flag ( :trap_exit , true ) Once exit trapping is enabled, an incoming exit signal becomes a mailbox message: { :EXIT , pid , reason }…

In the latest installment of this series, we dive into crafting a supervisor from scratch in Elixir. A supervisor is a process that monitors the health of worker processes and takes action when a worker fails. Our supervisor will manage two workers, restarting only the failed worker while leaving the other ones running. To achieve this, we will utilize the spawn/1, spawn_link/1, Process.flag(:trap_exit, true), send/2, and receive/1 functions.

Our supervisor won't rely on GenServer or OTP supervisor, but rather, we'll utilize the BEAM's built-in features for failure detection and restart policy. We will create a manual supervisor process, two workers, and a restart loop that uses the link between the supervisor and workers, along with exit signals and exit trapping, to monitor worker health and implement a restart policy.

Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.

Read the original at dev.to →

More in Tech

What I Checked Before Shipping a Browser Game to itch.io

I uploaded a small first-person sci-fi demo to itch.io this week. The build already ran in a normal browser, so I expected the upload to be the easy part.

  • Author verified game controls in clean environment
  • Tested window resizing and tab switching for focus issues
  • Disclosed AI-generated content on itch.io page

I shipped a Tokopedia scraper that undercuts the incumbents 5x — here's the boring part

I shipped a Tokopedia scraper that undercuts the incumbents 5x — here's the boring part Indonesia's biggest marketplace has a data problem: everyone wants to know what sells, at what price, from which…

  • Indonesia's largest marketplace lacks official sales data access
  • Scrapers are costly, similar to enterprise software solutions
  • Flat $0.005 per result pricing is five times cheaper than competitors

More from Tuesday 18 August →