Skip to content

Enable systemd socket activation for Grafito.#26

Merged
ralsina merged 1 commit into
ralsina:mainfrom
programmablereya:systemd-socket-activation
May 23, 2026
Merged

Enable systemd socket activation for Grafito.#26
ralsina merged 1 commit into
ralsina:mainfrom
programmablereya:systemd-socket-activation

Conversation

@programmablereya

Copy link
Copy Markdown
Contributor

Systemd socket activation allows the systemd daemon to control the server socket for a service, starting up the service upon receiving a connection on that socket. The socket is passed to the service, which accepts the new connection and any others that might arrive later.

This has multiple benefits, as described in the blog post here: https://0pointer.de/blog/projects/socket-activation.html Relevant to Grafito are:

  • the ability to shut down the service to update it without losing any requests
  • the ability to tightly sandbox the service so that it is unable to make any network requests without losing its core ability to receive and respond to requests made of it
  • the ability to conserve resources by only starting the service when it is needed

Grafito only really needs to be running when you want to look at your logs. And socket activation is half of that puzzle - it starts up Grafito when you want to use it. The other half is shutting Grafito down when it is no longer being used.

This change adds a new flag, --idle-timeout-sec, which causes Grafito to shut down after it has spent the prescribed time without receiving any new requests. When socket activation is used, Grafito does not shut down the socket when it shuts down, so any new requests which come in will be received by systemd, which will start it right back up again.

Systemd socket activation allows the systemd daemon to control the
server socket for a service, starting up the service upon receiving a
connection on that socket. The socket is passed to the service, which
accepts the new connection and any others that might arrive later.

This has multiple benefits, as described in the blog post here:
https://0pointer.de/blog/projects/socket-activation.html
Relevant to Grafito are:
* the ability to shut down the service to update it without losing
  any requests
* the ability to tightly sandbox the service so that it is unable to
  make any network requests without losing its core ability to receive
  and respond to requests made of it
* the ability to conserve resources by only starting the service when it
  is needed

Grafito only really needs to be running when you want to look at your
logs. And socket activation is half of that puzzle - it starts up
Grafito when you want to use it. The other half is shutting Grafito down
when it is no longer being used.

This change adds a new flag, --idle-timeout-sec, which causes Grafito to
shut down after it has spent the prescribed time without receiving any
new requests. When socket activation is used, Grafito does not shut down
the socket when it shuts down, so any new requests which come in will be
received by systemd, which will start it right back up again.
@ralsina

ralsina commented May 23, 2026

Copy link
Copy Markdown
Owner

Thanks for the PR, this is nice!

@ralsina ralsina merged commit 3562291 into ralsina:main May 23, 2026
1 check passed
@ralsina

ralsina commented May 23, 2026

Copy link
Copy Markdown
Owner

I will do a release over the weekend

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants