support systemd activation for api serve

systemd has a feature called socket activation where initially systemd
manages and listens on ports/uds and only invokes a service when traffic
appears. to then hand over the involved sockets, systemd will pass the
relevant FDs into the invoked process and defines them in the environment.

use coreos/go-systemd to grab the active listeners passed by systemd and
use them to serve the api routes. only one listener may be specified right
now as we also only support one -listen argument for the binary.

this allows admins to craft a systemd socket and service file for aptly
where systemd manages the socket, its permission and its live time, and
lazy start aptly when needed.
This commit is contained in:
Harald Sitter
2017-03-01 11:12:10 +01:00
parent 564ebf3130
commit 07cf8925f9
8 changed files with 226 additions and 5 deletions

View File

@@ -1,7 +1,7 @@
.\" generated with Ronn/v0.7.3
.\" http://github.com/rtomayko/ronn/tree/0.7.3
.
.TH "APTLY" "1" "February 2017" "" ""
.TH "APTLY" "1" "March 2017" "" ""
.
.SH "NAME"
\fBaptly\fR \- Debian repository management tool
@@ -1685,10 +1685,13 @@ host:port for HTTP listening
\fBaptly\fR \fBapi\fR \fBserve\fR
.
.P
Start HTTP server with aptly REST API\. The server can listen to either a port or Unix domain socket\. When using a socket, Aptly will fully manage the socket file\.
Start HTTP server with aptly REST API\. The server can listen to either a port or Unix domain socket\. When using a socket, Aptly will fully manage the socket file\. This command also supports taking over from a systemd file descriptors to enable systemd socket activation\.
.
.P
Example: $ aptly api serve \-listen=:8080 $ aptly api serve \-listen=unix:///tmp/aptly\.sock
Example:
.
.P
$ aptly api serve \-listen=:8080 $ aptly api serve \-listen=unix:///tmp/aptly\.sock
.
.P
Options: