thbar
Socket activation with systemd? (to reduce downtime on restart)
I’ve got a number of apps (e.g. Phoenix, but also pure Plug + Cowboy) where 1/ hot-reload cannot be easily used and 2/ the app runs on a single server.
The restart period can be a bit slow (and some apps are behind nginx too), which leads to a period during which the requests are refused (bad gateway etc).
I’m looking at ways to reduce that downtime.
Did anyone managed to use systemd “socket activation” together with either Phoenix or even Cowboy/Ranch directly?
For some context, here is how you can achieve that with Go:
or even with Python:
It could quite improve the deploy workflow of single-server setups.
If you have any information, let me know!
Thanks!
– Thibaut
Most Liked
idi527
![]()
It’s possible to pass fd option to :gen_tcp.listen: gen_tcp — OTP 29.0.2 (kernel 11.0.2). So something like
# not sure about this ...
config :app, App.Endpoint,
http: [transport_options: %{socket_opts: [fd: SYSTEMD_FIRST_SOCKET_FD]}]
might work.
So working from bottom up,
thbar
There are plenty of solutions to bypass the problem I’m tackling (like the one you are offering), yet in that case, I want specifically to try to solve the systemd activation thing & see if we can make it work.
Doing this because I think nginx + systemd will remain quite a common solution for entry-level deployments.
Thanks for the proposition, though, this is still helpful (& feel free to share your Envoy setup in a separate thread, by the way, it can definitely be interesting!).
thbar
I will experiment the coming week, on a client setup for which I need to do maintenance (Ansible + Elixir). Will report back with my findings!
Popular in Questions
Other popular topics
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









