Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HTTP: reuse socket from systemd if provided, allowing for systemd socket activation #2020

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

NickHu
Copy link

@NickHu NickHu commented Sep 30, 2021

Systemd can start services on-demand when a socket is polled. This is done as
follows:

  1. systemd listens on that socket from boot;
  2. when the socket first receives data:
    1. systemd starts the configured service (in this case, mopidy);
    2. systemd hands the socket over to the configured service.

The last part requires the application to support this, which is what this PR
implements.

Here is the contents of my ~/.config/systemd/user/mopidy.socket:

[Install]
WantedBy=sockets.target

[Socket]
Backlog=5
FileDescriptorName=http
KeepAlive=true
ListenStream=127.0.0.1:6680

(It starts mopidy.service).

mopidy/http/actor.py Outdated Show resolved Hide resolved
Copy link
Member

@jodal jodal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same feedback here as in Mopidy-MPD: The code would be cleaner with a get_systemd_socket() -> Optional[socket] function.

@kingosticks kingosticks added A-http Area: HTTP frontend C-enhancement Category: A PR with an enhancement or an issue with an enhancement proposal labels Jan 26, 2022
@jodal jodal deleted the branch mopidy:main March 1, 2024 23:15
@jodal jodal closed this Mar 1, 2024
@jodal jodal reopened this Mar 1, 2024
@jodal jodal changed the base branch from develop to main March 1, 2024 23:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-http Area: HTTP frontend C-enhancement Category: A PR with an enhancement or an issue with an enhancement proposal
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants