Blog

Atom feed – Tags: #elixir #emacs #nix

Implementing Long-Running HTTP Connections in Phoenix (override Cowboy's idle_timeout)

The Elixir language's actor programming model and the Phoenix web framework are particularly well-suited to implement long-running streaming HTTP connections, such as used in Server-Sent Events (SSE). For example, this blog post on Server-Sent Events with Elixir by Krister Viirsaar succinctly demonstrates how an SSE endpoint can be implemented in Phoenix without using any external libraries. However, the Cowboy HTTP server terminates idle connections after a globally-configured idle timeout, which is only reset when new data is received by clients. Also, SSE streams should send keep-alive messages regularly to ensure that clients, reverse-proxies, and middle-boxes don't close such connections. In this post, I will extend a minimal Phoenix SSE request endpoint example by adding keep-alive messages and overriding the Cowboy HTTP server idle timeout.

Read more...

Running Emacs in systemd's session.slice

I use Emacs and EXWM as my window manager. For this setup, running an Emacs daemon as a systemd-user unit allows me to attach multiple clients to this process (for instance, to work in the same session through an SSH connection on my iPad), and have the daemon survive restarts of my graphical session. However, all subprocesses started from within Emacs—which are virtually all applications & shells on my system—are then tracked within the same systemd scope. This means that a single application consuming excessive amounts of memory can bring down my entire user session (looking at you, Firefox). This post documents how you can move this Emacs daemon from the systemd app.slice into the more appropriate session.slice, and run applications & shells from within Emacs in their own scopes in app.slice.

Read more...