Skip to content

Conversation

@valpackett
Copy link

With socket activation, systemd can start the service when it's being used (and let it shut down when unused).

Example configuration:

~/.config/systemd/user/arrpc.socket

[Unit]
Description=arRPC Discord RPC bridge socket
Documentation=https://arrpc.openasar.dev/

[Socket]
ListenStream=127.0.0.1:1337
NoDelay=true

[Install]
WantedBy=sockets.target

~/.config/systemd/user/arrpc.service

[Unit]
Description=arRPC Discord RPC bridge
Documentation=https://arrpc.openasar.dev/

[Service]
#ExecStart=node %h/src/arrpc/src # (<<<use this instead of the below line with a path to a local git checkout, while the patch is not released yet)
ExecStart=npx arrpc
SendSIGHUP=true
Restart=on-failure
systemctl --user daemon-reload
systemctl --user enable --now arrpc.socket

(the units from discord-flatpak-rpc-bridge can be put into ~/.config/systemd/user/ as well btw)

Instead of opening a new port, inherit a socket from the parent process
when told to, so that systemd could spawn us only when someone actually
connects.
Allow saving memory by not running when Discord is not open.
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.

1 participant