dominicletz
Creator of Elixir Desktop
OnCrash - Method to attach a callback to a process exit
After having this done a couple of times in different projects I decided to make this quick helper method that creates a monitor, attaches it to the desired process and fires a fun when the process goes down.
So makes it easy as pie to attach a cleanup() function to a process:
spawn(fn ->
OnCrash.call(fn -> cleanup() end)
do_the_work()
end)
That’s really all there is to it. Ah and if you’re curious about the exit reason you can have that as well:
spawn(fn ->
OnCrash.call(fn reason -> cleanup(reason) end)
do_the_work()
end)
https://github.com/dominicletz/oncrash
Make a comment if this is helpful for you as well!
Cheers!
Popular in Announcing
Hello everybody :wave:
Recently, some of my colleagues talked about database ids and uuids and their problems, and I remembered the pain...
New
Hi everyone,
I’m coming from the Symfony (PHP) framework. I like Phoenix, but it has a one thing that was build much better in the Symfo...
New
Presenting Aviacommerce, open source e-commerce platform in Elixir
Aviacommerce is an open source e-commerce platform in Elixir. We at...
New
After working on it for a couple of months and using it in production for most of that time, today I’ve released LiveAdmin, a LiveView ba...
New
ExApi is a library that I’m developing now and hope release soon
This library will allow to:
list all apis
list all api implementation...
New
Earmark is a pure-Elixir Markdown converter.
It is intended to be used as a library (just call Earmark.as_html), but can also be used as...
New
Only 650 LOC, wrote for fun :slight_smile:
https://github.com/sunboshan/qrcode
New
I feel kind of stuck with the absence of a proper xml library for Elixir. Currently I use SweetXML which was ok for me more or less to pa...
New
Flop is an Elixir library that applies filtering, ordering and pagination parameters to your Ecto queries.
offset-based pagination with...
New
I’ve cleaned up and open sourced three financial libraries I was using for my company. They are bindings for the APIs of these three comp...
New
Other popular topics
None of the current solutions worked well for me, so I went ahead and built a user management system from scratch.
This project took far...
New
If I have a post route which an argument:
post /my_post_route/:my_param1, MyController.my_post_handler
How would get the post params ...
New
What is the difference between System.get_env and Application.get_env? For example, what are best practices to use one versus another.
New
I believe there are people here who are dealing with CSV files import on the daily basis, and since Excel is a really popular tool there ...
New
Hi all,
I’ve just started learning Elixir and Phoenix Framework, so please pardon my n00bness at this stage.
I’m trying to use Postgres...
New
Hello, I have map which I want to convert it to string like this:
the map:
%{last_name: "tavakkoli", name: "shahryar"}
the string I ne...
New
Surface is an experimental library built on top of Phoenix LiveView and its new LiveComponent API that aims to provide a more declarative...
New
Currently suffering from paralysis by [HTTP client] analysis. This is rather unusual in Elixirland as there tends to be consensus on the ...
New
Hello!
Sorry for this astonishing simple question, but I’m really stuck. I try to set up the intellij-elixir plugin, but I don’t know ho...
New
Hi everyone!
I need implement if…else if…else condition from my elixir code, and anymore of this control flow structures not work proper...
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
- #websockets
- #supervisor
- #advent-of-code
- #elixirconf-us
- #distillery
- #processes
- #forms
- #api
- #metaprogramming
- #security
- #performance









