arjan
Singleton - global, supervised singleton processes for Elixir
I created a tiny library which supervises “singleton” processes, using Erlang’s global module.
Processes which are started with Singleton.start_child/3 are guaranteed to run on one single node in your Elixir cluster. The nodes that don’t run the process, monitor it so that when it dies, it gets respawned, possibly on another node. This monitoring part is something that global doesn’t do for you.
It feels a bit “thin” for a hex package but I find it kind of useful (I’m using it as part of a bigger project, obviously). Anyway, check it out: GitHub - arjan/singleton: Global, supervised singleton processes for Elixir · GitHub
Trending in Announcing
You may know https://ui.shadcn.com/, a UI component library for React. I really love it’s design style and components. I’ve built some co...
New
Hey, I’m Jesse and I’m the main contributor behind Dexter, a full-featured, lightning-fast Elixir LSP optimized for large codebases. It s...
New
The Chelekom project is a library of Phoenix and LiveView components generated via Mix tasks to fit developer needs seamlessly.
One of i...
New
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
Hello everyone. After busy few months I am happy to announce v0.1.0 of Emerge & Solve.
They are GUI (Emerge) and State management (S...
New
Emily is an Elixir library that runs Nx computations on Apple’s MLX. Install it as the default Nx backend and Nx, defn, Axon, Nx.Serving,...
New
There are three potential reasons for members of this forum to have a look at https://vutuv.de
You are tired or annoyed of LinkedIn.
Yo...
New
Other Trending Topics
I just stumbled on a newly redesigned elixir-lang.org. :tada: It looks like @Software_Mansion did the work, and I think it is generally a...
New
@hugobarauna and I (Alex Koutmos) have been hard at work on writing a book on Nerves that takes you from simply blinking LEDs to building...
New
There has been a thread to discuss the Stack Overflow Developer Survey on this forum every year since 2018, so here’s yet another one for...
New
We want to introduce a new native datatype to Erlang: native records. Although replacing all tuple records with native records is not our...
New
I’m looking to build a personal workflow to quickly deploy web applications written in elixir/phoenix, for local consumption (ie not on t...
New
Fly’s CEO posted this recently - Turn And Face The Strange · The Fly Blog
It says that Fly is going all-in on sprites, which is a worry ...
New
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #channels
- #elixirconf
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #phoenix_html
- #iex
- #blog-post
- #graphql
- #genstage
- #ai
- #elixirconf-us
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #metaprogramming
- #hex
- #performance










First 4 of 4 Posts
Tuxified
Sounds useful, thanks. Might be something for a lighting talk? Judging by the amount of hex packages, perhaps even a
Arjans toolbox-talkbodgix
Hi.
Thanks for putting the library together.
Before I found it, I’ve been trying to hack my own implementation and I ended up with a very similar code as yours.
However, both your code and mine suffers from an unexpected behavior.
When a 2nd node joins the cluster, I do see:
But what is unexpected is that not only the singleton process is terminated, but the whole application on one of the nodes:
And one of the nodes basically is left in a state where my own application is not running, only the “libraries” continue running.
I’ve been struggling with the same issue in my own implementation.
I created a DynamicSupervisor for the singleton process, similarly to you and I was hoping that it will “shield” the main Application supervisor from crashing when the :global registry kills one of the singleton processes.
However, that doesn’t seem to be the case and the whole application dies regardless of multiple layers of supervisors
Using Elixir version 1.12.3
Abdallah94
@bodgix have you managed to solve this issue? we’re facing the same problem
al2o3cr
What is
restartset to in the “singleton” GenServer? If it’s set to the default:permanent, then the supervisor on the joined node will keep restarting the process over and over again until it also gives up, cascading down the chain of supervisors until the whole application stops.Does the behavior change if you specify
use GenServer, restart: :temporary?