LinuxCommandLibrary
GitHubF-DroidGoogle Play Store

systemd-socket-activate

Test socket activation of daemons

TLDR

Listen on a port and launch a command on connection
$ systemd-socket-activate -l [8080] [command]
copy
Listen on multiple ports for a command
$ systemd-socket-activate -l [8080] -l [8081] [command]
copy
Accept connections and spawn a new instance for each
$ systemd-socket-activate -l [8080] -a [command]
copy
Use datagram (UDP) sockets instead of stream (TCP)
$ systemd-socket-activate -l [8080] -d [command]
copy
Set environment variables for the launched process
$ systemd-socket-activate -l [8080] -E [VAR=value] [command]
copy
Run in inetd compatibility mode
$ systemd-socket-activate -l [8080] --inetd [command]
copy

SYNOPSIS

systemd-socket-activate [options] command [arguments]

DESCRIPTION

systemd-socket-activate is a test and development tool for socket activation. It listens on sockets and launches a specified command when connections arrive, simulating systemd's socket activation feature without needing to configure full socket and service unit files.By default it listens on a stream (TCP) socket. Use --datagram for UDP or --seqpacket for sequential packet sockets. The activated program receives the socket file descriptors via the $LISTEN_FDS protocol (or via stdin/stdout in --inetd mode).

PARAMETERS

-l ADDRESS, --listen=ADDRESS

Listen on the specified address (port number or host:port).
-a, --accept
Launch a new instance of the command for each connection. Cannot be combined with --now.
-d, --datagram
Listen on a datagram socket (SOCK_DGRAM) instead of a stream socket. Cannot be combined with --seqpacket.
--seqpacket
Listen on a sequential packet socket (SOCK_SEQPACKET) instead of a stream socket. Cannot be combined with --datagram.
-E VAR[=VALUE], --setenv=VAR[=VALUE]
Set an environment variable for the launched process. If no value given, inherits from the current environment.
--fdname=NAME[:NAME...]
Specify names for the file descriptors passed. Enables use of sdlistenfdswithnames(3).
--inetd
Use the inetd protocol for passing file descriptors (as stdin/stdout) instead of the $LISTEN_FDS protocol.
--now
Start the command immediately instead of waiting for a connection. Cannot be combined with --accept.
-h, --help
Display help information.
--version
Display version information.

CAVEATS

Primarily intended for testing, not production use. For production, configure proper systemd socket and service units. The service must support socket activation protocol. Part of the systemd suite.

SEE ALSO

Copied to clipboard
Kai