[PATCH] services: nginx: Add support for extra content in upstream blocks.

  • Done
  • quality assurance status badge
Details
One participant
  • Christopher Baines
Owner
unassigned
Submitted by
Christopher Baines
Severity
normal
C
C
Christopher Baines wrote on 23 Jun 2022 13:45
(address . guix-patches@gnu.org)
20220623114500.13409-1-mail@cbaines.net
I'm looking at this as I'd like to use the keepalive functionality.

* gnu/services/web.scm (nginx-upstream-configuration-extra-content): New
procedure.
(emit-nginx-upstream-config): Include the extra-content if applicable.
* doc/guix.texi (NGINX): Document this.
---
doc/guix.texi | 3 +++
gnu/services/web.scm | 14 +++++++++++++-
2 files changed, 16 insertions(+), 1 deletion(-)

Toggle diff (55 lines)
diff --git a/doc/guix.texi b/doc/guix.texi
index bbb7d0764d..0a96ad1852 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -28490,6 +28490,9 @@ prefix @samp{unix:}. For addresses using an IP address or domain name,
the default port is 80, and a different port can be specified
explicitly.
+@item @code{extra-content}
+A string or list of strings to add to the upstream block.
+
@end table
@end deftp
diff --git a/gnu/services/web.scm b/gnu/services/web.scm
index 4f06d4e0bb..4434fecf02 100644
--- a/gnu/services/web.scm
+++ b/gnu/services/web.scm
@@ -120,6 +120,7 @@ (define-module (gnu services web)
nginx-upstream-configuration?
nginx-upstream-configuration-name
nginx-upstream-configuration-servers
+ nginx-upstream-configuration-extra-content
nginx-location-configuration
nginx-location-configuration?
@@ -517,7 +518,9 @@ (define-record-type* <nginx-upstream-configuration>
nginx-upstream-configuration make-nginx-upstream-configuration
nginx-upstream-configuration?
(name nginx-upstream-configuration-name)
- (servers nginx-upstream-configuration-servers))
+ (servers nginx-upstream-configuration-servers)
+ (extra-content nginx-upstream-configuration-extra-content
+ (default '())))
(define-record-type* <nginx-location-configuration>
nginx-location-configuration make-nginx-location-configuration
@@ -643,6 +646,15 @@ (define (emit-nginx-upstream-config upstream)
(map (lambda (server)
(simple-format #f " server ~A;\n" server))
(nginx-upstream-configuration-servers upstream))
+ (let ((extra-content
+ (nginx-upstream-configuration-extra-content upstream)))
+ (if (and extra-content (not (null? extra-content)))
+ (cons
+ "\n"
+ (map (lambda (line)
+ (simple-format #f " ~A\n" line))
+ (flatten extra-content)))
+ '()))
" }\n"))
(define (flatten . lst)
--
2.36.1
C
C
Christopher Baines wrote on 1 Jul 2022 10:48
(name . Christopher Baines)(address . mail@cbaines.net)(address . 56164-done@debbugs.gnu.org)
878rpd1amf.fsf@cbaines.net
Christopher Baines <mail@cbaines.net> writes:

Toggle quote (11 lines)
> I'm looking at this as I'd like to use the keepalive functionality.
>
> * gnu/services/web.scm (nginx-upstream-configuration-extra-content): New
> procedure.
> (emit-nginx-upstream-config): Include the extra-content if applicable.
> * doc/guix.texi (NGINX): Document this.
> ---
> doc/guix.texi | 3 +++
> gnu/services/web.scm | 14 +++++++++++++-
> 2 files changed, 16 insertions(+), 1 deletion(-)

I've gone ahead and pushed this as
b5c6062bcec9530a9c4044a1bd1091fdebf9bc74.
-----BEGIN PGP SIGNATURE-----

iQKlBAEBCgCPFiEEPonu50WOcg2XVOCyXiijOwuE9XcFAmK+tPhfFIAAAAAALgAo
aXNzdWVyLWZwckBub3RhdGlvbnMub3BlbnBncC5maWZ0aGhvcnNlbWFuLm5ldDNF
ODlFRUU3NDU4RTcyMEQ5NzU0RTBCMjVFMjhBMzNCMEI4NEY1NzcRHG1haWxAY2Jh
aW5lcy5uZXQACgkQXiijOwuE9XeoLA//ZbmgSTU0TejgnFUDFyNK73Tzz5sVVPtx
rzLkytSnWZJoawaneqqTt8YvwJiB6LmjNMEM8B5tqxA2SnegYfOmdTeTB44EMr8k
bH/ots3dDIs0hdlmy3VnWD1CFYifBrCTaaCAGWFlqB+KwLCA3TiF2FSswr2nfQC6
AYez3QfcXNcReC9s1NlJ0VJ1nq/uOI0MYdb1Hilc/P3ZetpLPje/iBSaGcOn3xdH
2FqClXan/Ise+Bt5wbr2nmZjceqyOUBLDcyxwuI2x37cTn7yyzcjmjW/YBja63bl
y5oVxXfcoklAWNmGbVFll52QhwzI/NtFaKE2sTplLVfGN81shWuJ2w5rTdCPzVZy
qX+/BIchlqy2rjXxsPueP0ul8f8EkG3N4yxKGd3HxPXZchiRJ6xeYZ2w8p1zgK8u
g/s/xBjt8SfxWkrwaCqVysPPr9lYwkoEE5PT4mWWNjV9ezDXK54H//PuZfpl44/x
8NXbhMLX8ZKst6NvHFKzZS7BRTX158UaAedy0DpBiJh5aIw6XTUpO4IrGhnMLffr
Rb/eDyGHUlD9qgCqJmjv66BE3WAr/4P0dxpg+vLlv5+ZG+BYUY0hVWbcWEU5KyJX
hcWYwrH+W70opjbRVO5IMSdMr0BaeYEpQq/rvwoyWcQHBF6h/PVS5EEjhwA1wjrZ
ROBrORVqjXM=
=Xne/
-----END PGP SIGNATURE-----

Closed
?