[PATCH] gnu: services: admin: Add tailon.

  • Done
  • quality assurance status badge
Details
2 participants
  • Ludovic Courtès
  • Christopher Baines
Owner
unassigned
Submitted by
Christopher Baines
Severity
normal

Debbugs page

Christopher Baines wrote 8 years ago
(address . guix-patches@gnu.org)
20170711065634.9717-1-mail@cbaines.net
* gnu/services/admin.scm
(<tailon-configuration>, <tailon-configuration-file>): New record types.
(tailon-configuration-files-string, tailon-shepherd-service): New
procedures.
(%tailon-accounts, tailon-service-type: New variables.
* doc/guix.text (Monitoring Services: Document the Tailon service.
---
doc/guix.texi | 88 +++++++++++++++++++++++++++++
gnu/services/admin.scm | 150 ++++++++++++++++++++++++++++++++++++++++++++++++-
2 files changed, 237 insertions(+), 1 deletion(-)

Toggle diff (296 lines)
diff --git a/doc/guix.texi b/doc/guix.texi
index 729ec081b..164dccba1 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -218,6 +218,7 @@ Services
* Database Services:: SQL databases.
* Mail Services:: IMAP, POP3, SMTP, and all that.
* Messaging Services:: Messaging services.
+* Monitoring Services:: Monitoring services.
* Kerberos Services:: Kerberos services.
* Web Services:: Web servers.
* DNS Services:: DNS daemons.
@@ -8901,6 +8902,7 @@ declaration.
* Database Services:: SQL databases.
* Mail Services:: IMAP, POP3, SMTP, and all that.
* Messaging Services:: Messaging services.
+* Monitoring Services:: Monitoring services.
* Kerberos Services:: Kerberos services.
* Web Services:: Web servers.
* DNS Services:: DNS daemons.
@@ -13489,6 +13491,92 @@ string, you could instantiate a prosody service like this:
(prosody.cfg.lua "")))
@end example
+@node Monitoring Services
+@subsubsection Monitoring Services
+
+@subsubheading Tailon Service
+
+Tailon is a web application for viewing and searching log files.
+
+The following example will configure the service with default values.
+By default, Tailon can be accessed on port 8080 (http://localhost:8080).
+
+@example
+(service tailon-service-type)
+@end example
+
+The following example customises more of the Tailon configuration,
+adding ``sed'' to the list of allowed commands.
+
+@example
+(service tailon-service-type
+ (tailon-configuration
+ (config-file
+ (tailon-configuration-file
+ (allowed-commands '("tail" "grep" "awk" "sed"))))))
+@end example
+
+
+@deftp {Data Type} tailon-configuration
+Data type representing the configuration of tailon.
+This type has the following parameters:
+
+@table @asis
+@item @code{config-file} (default: @code{(tailon-configuration-file)})
+The configuration file to use for Tailon. This can be set to a
+@dfn{tailon-configuration-file} record value, or any gexp
+(@pxref{G-Expressions}).
+
+For example, to instead use a local file, the @code{local-file} function
+can be used:
+
+@example
+(service tailon-service-type
+ (tailon-configuration
+ (config-file (local-file "./my-tailon.conf"))))
+@end example
+
+@item @code{package} (default: @code{tailon})
+The tailon package to use.
+
+@end table
+@end deftp
+
+@deftp {Data Type} tailon-configuration-file
+Data type representing the configuration options for Tailon.
+This type has the following parameters:
+
+@table @asis
+@item @code{paths} (default: @code{(list "/var/log")})
+List of paths to display. Can include strings for a single path, or a
+list, where the first item is the name of a subsection, and the
+remaining items are in that subsection.
+
+@item @code{bind} (default: @code{"localhost:8080"})
+Address and port to which Tailon should bind on.
+
+@item @code{relative-root-path} (default: @code{#f})
+Prefix to use for all paths, set to @code{#f} to disable using a prefix.
+
+@item @code{allow-transfers?} (default: @code{#t})
+Allow downloading the log files in the web interface.
+
+@item @code{follow-names?} (default: @code{#t})
+Allow tailing of not-yet existent files.
+
+@item @code{tail-lines} (default: @code{200})
+Number of lines to read initially from each file.
+
+@item @code{allowed-commands} (default: @code{(list "tail" "grep" "awk")})
+Commands to allow running. By default, @code{sed} is disabled.
+
+@item @code{debug?} (default: @code{#f})
+Set @code{debug?} to @code{#t} to show debug messages.
+
+@end table
+@end deftp
+
+
@node Kerberos Services
@subsubsection Kerberos Services
@cindex Kerberos
diff --git a/gnu/services/admin.scm b/gnu/services/admin.scm
index b9e3fa70a..eb1f70ec6 100644
--- a/gnu/services/admin.scm
+++ b/gnu/services/admin.scm
@@ -20,14 +20,19 @@
(define-module (gnu services admin)
#:use-module (gnu packages admin)
#:use-module (gnu packages base)
+ #:use-module (gnu packages logging)
#:use-module (gnu services)
#:use-module (gnu services mcron)
#:use-module (gnu services shepherd)
+ #:use-module (gnu services web)
+ #:use-module (gnu system shadow)
#:use-module (guix gexp)
+ #:use-module (guix store)
#:use-module (guix packages)
#:use-module (guix records)
#:use-module (srfi srfi-1)
#:use-module (ice-9 vlist)
+ #:use-module (ice-9 match)
#:export (%default-rotations
%rotated-files
@@ -41,7 +46,27 @@
rottlog-configuration
rottlog-configuration?
rottlog-service
- rottlog-service-type))
+ rottlog-service-type
+
+ <tailon-configuration-file>
+ tailon-configuration-file
+ tailon-configuration-file?
+ tailon-configuration-file-paths
+ tailon-configuration-file-bind
+ tailon-configuration-file-relative-root-path
+ tailon-configuration-file-allow-transfers?
+ tailon-configuration-file-follow-names?
+ tailon-configuration-file-tail-lines
+ tailon-configuration-file-allowed-commands
+ tailon-configuration-file-debug?
+
+ <tailon-configuration>
+ tailon-configuration
+ tailon-configuration?
+ tailon-configuration-config-file
+ tailon-configuration-package
+
+ tailon-service-type))
;;; Commentary:
;;;
@@ -172,4 +197,127 @@ for ROTATION."
rotations)))))
(default-value (rottlog-configuration))))
+
+;;;
+;;; Tailon
+;;;
+
+(define-record-type* <tailon-configuration-file>
+ tailon-configuration-file make-tailon-configuration-file
+ tailon-configuration-file?
+ (paths tailon-configuration-paths
+ (default '("/var/log")))
+ (bind tailon-configuration-file-bind
+ (default "localhost:8080"))
+ (relative-root-path tailon-configuration-file-relative-root-path
+ (default #f))
+ (allow-transfers? tailon-configuration-file-allow-transfers?
+ (default #t))
+ (follow-names? tailon-configuration-file-follow-names?
+ (default #t))
+ (tail-lines tailon-configuration-file-tail-lines
+ (default 200))
+ (allowed-commands tailon-configuration-file-allowed-commands
+ (default '("tail" "grep" "awk")))
+ (debug? tailon-configuration-file-debug?
+ (default #f)))
+
+(define (tailon-configuration-files-string paths)
+ (string-append
+ "\n"
+ (string-join
+ (map
+ (lambda (x)
+ (string-append
+ " - "
+ (cond
+ ((string? x)
+ (simple-format #f "'~A'" x))
+ ((list? x)
+ (string-join
+ (cons (simple-format #f "'~A':" (car x))
+ (map
+ (lambda (x) (simple-format #f " - '~A'" x))
+ (cdr x)))
+ "\n"))
+ (else (error x)))))
+ paths)
+ "\n")))
+
+(define-gexp-compiler (tailon-configuration-file-compiler
+ (file <tailon-configuration-file>) system target)
+ (match file
+ (($ <tailon-configuration-file> paths bind relative-root-path
+ allow-transfers? follow-names?
+ tail-lines allowed-commands debug?)
+ (text-file
+ "tailon-config.yaml"
+ (string-concatenate
+ (filter-map
+ (match-lambda
+ ((key . #f) #f)
+ ((key . value) (string-append key ": " value "\n")))
+
+ `(("files" . ,(tailon-configuration-files-string paths))
+ ("bind" . ,bind)
+ ("relative-root" . ,relative-root-path)
+ ("allow-transfers" . ,(if allow-transfers? "true" "false"))
+ ("follow-names" . ,(if follow-names? "true" "false"))
+ ("tail-lines" . ,(number->string tail-lines))
+ ("commands" . ,(string-append "["
+ (string-join allowed-commands ", ")
+ "]"))
+ ,@(if debug? '(("debug" . "true")) '()))))))))
+
+(define-record-type* <tailon-configuration>
+ tailon-configuration make-tailon-configuration
+ tailon-configuration?
+ (config-file tailon-configuration-config-file
+ (default (tailon-configuration-file)))
+ (package tailon-configuration-package
+ (default tailon)))
+
+(define tailon-shepherd-service
+ (match-lambda
+ (($ <tailon-configuration> config-file package)
+ (list (shepherd-service
+ (provision '(tailon))
+ (documentation "Run the tailon daemon.")
+ (start #~(make-forkexec-constructor
+ `(,(string-append #$package "/bin/tailon")
+ "-c" ,#$config-file)
+ #:user "tailon"
+ #:group "tailon"))
+ (stop #~(make-kill-destructor)))))))
+
+(define %tailon-accounts
+ (list (user-group (name "tailon") (system? #t))
+ (user-account
+ (name "tailon")
+ (group "tailon")
+ (system? #t)
+ (comment "tailon")
+ (home-directory "/var/empty")
+ (shell (file-append shadow "/sbin/nologin")))))
+
+(define tailon-service-type
+ (service-type
+ (name 'tailon)
+ (extensions
+ (list (service-extension shepherd-root-service-type
+ tailon-shepherd-service)
+ (service-extension account-service-type
+ (const %tailon-accounts))))
+ (compose concatenate)
+ (extend (lambda (parameter paths)
+ (tailon-configuration
+ (inherit parameter)
+ (config-file
+ (let ((old-config-file (tailon-configuration-config-file parameter)))
+ (tailon-configuration-file
+ (inherit old-config-file)
+ (paths (append (tailon-configuration-paths old-config-file)
+ paths))))))))
+ (default-value (tailon-configuration))))
+
;;; admin.scm ends here
--
2.13.1
Ludovic Courtès wrote 8 years ago
(name . Christopher Baines)(address . mail@cbaines.net)(address . 27650@debbugs.gnu.org)
87shi1etui.fsf@gnu.org
Hi Christopher,

Christopher Baines <mail@cbaines.net> skribis:

Toggle quote (7 lines)
> * gnu/services/admin.scm
> (<tailon-configuration>, <tailon-configuration-file>): New record types.
> (tailon-configuration-files-string, tailon-shepherd-service): New
> procedures.
> (%tailon-accounts, tailon-service-type: New variables.
> * doc/guix.text (Monitoring Services: Document the Tailon service.

Neat. Maybe a service we could take advantage of on our build farm
machines?

s/text/texi/ :-)

Toggle quote (7 lines)
> +@node Monitoring Services
> +@subsubsection Monitoring Services
> +
> +@subsubheading Tailon Service
> +
> +Tailon is a web application for viewing and searching log files.

Please write @uref{https://…, Tailon} so readers can read more about it
if needed.

Toggle quote (2 lines)
> +The following example will configure the service with default values.
> +By default, Tailon can be accessed on port 8080 (http://localhost:8080).
^
@code

Toggle quote (2 lines)
> +The following example customises more of the Tailon configuration,
> +adding ``sed'' to the list of allowed commands.
^^
@command{sed}

Toggle quote (3 lines)
> +@deftp {Data Type} tailon-configuration
> +Data type representing the configuration of tailon.

Tailon (capital).

Toggle quote (6 lines)
> +@table @asis
> +@item @code{paths} (default: @code{(list "/var/log")})
> +List of paths to display. Can include strings for a single path, or a
> +list, where the first item is the name of a subsection, and the
> +remaining items are in that subsection.

Please s/paths/directories/ (in GNU the convention is to use “file name”
or “directory name”, whereas “path” is reserved for search paths.)

Toggle quote (7 lines)
> + (paths tailon-configuration-paths
> + (default '("/var/log")))
> + (bind tailon-configuration-file-bind
> + (default "localhost:8080"))
> + (relative-root-path tailon-configuration-file-relative-root-path
> + (default #f))

Same here.

Toggle quote (3 lines)
> +(define-gexp-compiler (tailon-configuration-file-compiler
> + (file <tailon-configuration-file>) system target)

That’s a good idea. :-)

Otherwise LGTM!

Bonus points if you write a system test that checks that at least the
Web server shows up on port 8080.

Thank you!

Ludo’.
Christopher Baines wrote 8 years ago
(name . Ludovic Courtès)(address . ludo@gnu.org)(address . 27650@debbugs.gnu.org)
20170716165149.48c2fe19@cbaines.net
On Wed, 12 Jul 2017 14:13:25 +0200
ludo@gnu.org (Ludovic Courtès) wrote:

Toggle quote (14 lines)
> Hi Christopher,
>
> Christopher Baines <mail@cbaines.net> skribis:
>
> > * gnu/services/admin.scm
> > (<tailon-configuration>, <tailon-configuration-file>): New record
> > types. (tailon-configuration-files-string,
> > tailon-shepherd-service): New procedures.
> > (%tailon-accounts, tailon-service-type: New variables.
> > * doc/guix.text (Monitoring Services: Document the Tailon service.
>
> Neat. Maybe a service we could take advantage of on our build farm
> machines?

Thanks for your review, I'll send an updated patch with the texinfo
improvements, and the path/file/directory naming changes.

Toggle quote (6 lines)
> > +(define-gexp-compiler (tailon-configuration-file-compiler
> > + (file <tailon-configuration-file>) system
> > target)
>
> That’s a good idea. :-)

I'm glad you think so. This pattern should make either using the
provided record type, or something else very easy, as there are no
special cases in the service code.

Toggle quote (3 lines)
> Bonus points if you write a system test that checks that at least the
> Web server shows up on port 8080.

I've had a go at this, I'll send a separate patch. It doesn't pass for
me yet, and I'm not sure how to work out what is going on inside the
test system, does anyone have any tips for writing and debugging system
tests in general?
-----BEGIN PGP SIGNATURE-----

iQKTBAEBCgB9FiEEPonu50WOcg2XVOCyXiijOwuE9XcFAllri5VfFIAAAAAALgAo
aXNzdWVyLWZwckBub3RhdGlvbnMub3BlbnBncC5maWZ0aGhvcnNlbWFuLm5ldDNF
ODlFRUU3NDU4RTcyMEQ5NzU0RTBCMjVFMjhBMzNCMEI4NEY1NzcACgkQXiijOwuE
9XfnUw//aq2fvToXiP0tPpX6/2g5Ozg/BQlh3qye+39DnuI67+0NNJHLfVE33cb3
7PKhEJ/Q2Orrt4pbRlzzds+6o3E7CP8u44gcI44y15jjOJ4FxTfFYEmOw9WACJzT
iMcRLaDy7/o0ng0R+IXz/9LLvNfzlbham/ikJCoETD9MCOiMruS1ivKABKXpGj/f
1lEEyhHQCT1ryKSmw3W6Bl41WYEuQ5KonDT4W9yJUObxbP6Py3lURbEwtkfECJvf
BKALyfMaghyPB/az7ZjJZstPysPaDo6zJVYf6M4itGVXrvk9JBl9FD1XQJylo9fz
s7spjhBMeNnsBEhDk+TOF6EpVI5/76ixpPJnbUvTI/9vSgsbJfB2LSMxEhNeuhBs
Po44tV6nUceJPYNaPS3Gbgf39Q1kDjZDMq+kX6u5xs1f+ERCE4JfdEPz2Mf9TYJ0
Iy6Ffo5CNM4vnRfK5b/N0hSWAzcV7vTvebtMabMVgm2a6xc0ICkgcNvm7DjNPFqK
PTZBdh2OtPI8t/baRGEegcye+xfuSiV3bpyL5r8GDOBfntXFEEXw94xw8wLdx4kq
Dk1dxPU41/Y618MHLkyerRB2hEy6+zCw6RrivbnsN6e/2PBiSHBK5ILgdBysioyB
XPRBsi86Vga+T0M09z4KtIP+cs+fqSD2FVyFVys64ToUhV+VZ10=
=n+eA
-----END PGP SIGNATURE-----


Christopher Baines wrote 8 years ago
[PATCH] gnu: services: admin: Add tailon.
(address . 27650@debbugs.gnu.org)
20170716155226.13689-1-mail@cbaines.net
* gnu/services/admin.scm
(<tailon-configuration>, <tailon-configuration-file>): New record types.
(tailon-configuration-files-string, tailon-shepherd-service): New
procedures.
(%tailon-accounts, tailon-service-type: New variables.
* doc/guix.texi (Monitoring Services: Document the Tailon service.
---
doc/guix.texi | 89 +++++++++++++++++++++++++++++
gnu/services/admin.scm | 151 ++++++++++++++++++++++++++++++++++++++++++++++++-
2 files changed, 239 insertions(+), 1 deletion(-)

Toggle diff (298 lines)
diff --git a/doc/guix.texi b/doc/guix.texi
index ecf961772..1226e1721 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -218,6 +218,7 @@ Services
* Database Services:: SQL databases.
* Mail Services:: IMAP, POP3, SMTP, and all that.
* Messaging Services:: Messaging services.
+* Monitoring Services:: Monitoring services.
* Kerberos Services:: Kerberos services.
* Web Services:: Web servers.
* DNS Services:: DNS daemons.
@@ -8921,6 +8922,7 @@ declaration.
* Database Services:: SQL databases.
* Mail Services:: IMAP, POP3, SMTP, and all that.
* Messaging Services:: Messaging services.
+* Monitoring Services:: Monitoring services.
* Kerberos Services:: Kerberos services.
* Web Services:: Web servers.
* DNS Services:: DNS daemons.
@@ -13509,6 +13511,93 @@ string, you could instantiate a prosody service like this:
(prosody.cfg.lua "")))
@end example
+@node Monitoring Services
+@subsubsection Monitoring Services
+
+@subsubheading Tailon Service
+
+@uref{https://tailon.readthedocs.io/, Tailon} is a web application for
+viewing and searching log files.
+
+The following example will configure the service with default values.
+By default, Tailon can be accessed on port 8080 (@code{http://localhost:8080}).
+
+@example
+(service tailon-service-type)
+@end example
+
+The following example customises more of the Tailon configuration,
+adding @command{sed} to the list of allowed commands.
+
+@example
+(service tailon-service-type
+ (tailon-configuration
+ (config-file
+ (tailon-configuration-file
+ (allowed-commands '("tail" "grep" "awk" "sed"))))))
+@end example
+
+
+@deftp {Data Type} tailon-configuration
+Data type representing the configuration of Tailon.
+This type has the following parameters:
+
+@table @asis
+@item @code{config-file} (default: @code{(tailon-configuration-file)})
+The configuration file to use for Tailon. This can be set to a
+@dfn{tailon-configuration-file} record value, or any gexp
+(@pxref{G-Expressions}).
+
+For example, to instead use a local file, the @code{local-file} function
+can be used:
+
+@example
+(service tailon-service-type
+ (tailon-configuration
+ (config-file (local-file "./my-tailon.conf"))))
+@end example
+
+@item @code{package} (default: @code{tailon})
+The tailon package to use.
+
+@end table
+@end deftp
+
+@deftp {Data Type} tailon-configuration-file
+Data type representing the configuration options for Tailon.
+This type has the following parameters:
+
+@table @asis
+@item @code{files} (default: @code{(list "/var/log")})
+List of files to display. The list can include strings for a single
+file, or a list, where the first item is the name of a subsection, and
+the remaining items are the files in that subsection.
+
+@item @code{bind} (default: @code{"localhost:8080"})
+Address and port to which Tailon should bind on.
+
+@item @code{relative-root-path} (default: @code{#f})
+Prefix to use for all paths, set to @code{#f} to disable using a prefix.
+
+@item @code{allow-transfers?} (default: @code{#t})
+Allow downloading the log files in the web interface.
+
+@item @code{follow-names?} (default: @code{#t})
+Allow tailing of not-yet existent files.
+
+@item @code{tail-lines} (default: @code{200})
+Number of lines to read initially from each file.
+
+@item @code{allowed-commands} (default: @code{(list "tail" "grep" "awk")})
+Commands to allow running. By default, @code{sed} is disabled.
+
+@item @code{debug?} (default: @code{#f})
+Set @code{debug?} to @code{#t} to show debug messages.
+
+@end table
+@end deftp
+
+
@node Kerberos Services
@subsubsection Kerberos Services
@cindex Kerberos
diff --git a/gnu/services/admin.scm b/gnu/services/admin.scm
index b9e3fa70a..26b5c6edb 100644
--- a/gnu/services/admin.scm
+++ b/gnu/services/admin.scm
@@ -20,14 +20,19 @@
(define-module (gnu services admin)
#:use-module (gnu packages admin)
#:use-module (gnu packages base)
+ #:use-module (gnu packages logging)
#:use-module (gnu services)
#:use-module (gnu services mcron)
#:use-module (gnu services shepherd)
+ #:use-module (gnu services web)
+ #:use-module (gnu system shadow)
#:use-module (guix gexp)
+ #:use-module (guix store)
#:use-module (guix packages)
#:use-module (guix records)
#:use-module (srfi srfi-1)
#:use-module (ice-9 vlist)
+ #:use-module (ice-9 match)
#:export (%default-rotations
%rotated-files
@@ -41,7 +46,27 @@
rottlog-configuration
rottlog-configuration?
rottlog-service
- rottlog-service-type))
+ rottlog-service-type
+
+ <tailon-configuration-file>
+ tailon-configuration-file
+ tailon-configuration-file?
+ tailon-configuration-file-files
+ tailon-configuration-file-bind
+ tailon-configuration-file-relative-root-directory
+ tailon-configuration-file-allow-transfers?
+ tailon-configuration-file-follow-names?
+ tailon-configuration-file-tail-lines
+ tailon-configuration-file-allowed-commands
+ tailon-configuration-file-debug?
+
+ <tailon-configuration>
+ tailon-configuration
+ tailon-configuration?
+ tailon-configuration-config-file
+ tailon-configuration-package
+
+ tailon-service-type))
;;; Commentary:
;;;
@@ -172,4 +197,128 @@ for ROTATION."
rotations)))))
(default-value (rottlog-configuration))))
+
+;;;
+;;; Tailon
+;;;
+
+(define-record-type* <tailon-configuration-file>
+ tailon-configuration-file make-tailon-configuration-file
+ tailon-configuration-file?
+ (files tailon-configuration-file-files
+ (default '("/var/log")))
+ (bind tailon-configuration-file-bind
+ (default "localhost:8080"))
+ (relative-root-directory tailon-configuration-file-relative-root-directory
+ (default #f))
+ (allow-transfers? tailon-configuration-file-allow-transfers?
+ (default #t))
+ (follow-names? tailon-configuration-file-follow-names?
+ (default #t))
+ (tail-lines tailon-configuration-file-tail-lines
+ (default 200))
+ (allowed-commands tailon-configuration-file-allowed-commands
+ (default '("tail" "grep" "awk")))
+ (debug? tailon-configuration-file-debug?
+ (default #f)))
+
+(define (tailon-configuration-files-string files)
+ (string-append
+ "\n"
+ (string-join
+ (map
+ (lambda (x)
+ (string-append
+ " - "
+ (cond
+ ((string? x)
+ (simple-format #f "'~A'" x))
+ ((list? x)
+ (string-join
+ (cons (simple-format #f "'~A':" (car x))
+ (map
+ (lambda (x) (simple-format #f " - '~A'" x))
+ (cdr x)))
+ "\n"))
+ (else (error x)))))
+ files)
+ "\n")))
+
+(define-gexp-compiler (tailon-configuration-file-compiler
+ (file <tailon-configuration-file>) system target)
+ (match file
+ (($ <tailon-configuration-file> files bind relative-root-directory
+ allow-transfers? follow-names?
+ tail-lines allowed-commands debug?)
+ (text-file
+ "tailon-config.yaml"
+ (string-concatenate
+ (filter-map
+ (match-lambda
+ ((key . #f) #f)
+ ((key . value) (string-append key ": " value "\n")))
+
+ `(("files" . ,(tailon-configuration-files-string files))
+ ("bind" . ,bind)
+ ("relative-root" . ,relative-root-directory)
+ ("allow-transfers" . ,(if allow-transfers? "true" "false"))
+ ("follow-names" . ,(if follow-names? "true" "false"))
+ ("tail-lines" . ,(number->string tail-lines))
+ ("commands" . ,(string-append "["
+ (string-join allowed-commands ", ")
+ "]"))
+ ,@(if debug? '(("debug" . "true")) '()))))))))
+
+(define-record-type* <tailon-configuration>
+ tailon-configuration make-tailon-configuration
+ tailon-configuration?
+ (config-file tailon-configuration-config-file
+ (default (tailon-configuration-file)))
+ (package tailon-configuration-package
+ (default tailon)))
+
+(define tailon-shepherd-service
+ (match-lambda
+ (($ <tailon-configuration> config-file package)
+ (list (shepherd-service
+ (provision '(tailon))
+ (documentation "Run the tailon daemon.")
+ (start #~(make-forkexec-constructor
+ `(,(string-append #$package "/bin/tailon")
+ "-c" ,#$config-file)
+ #:user "tailon"
+ #:group "tailon"))
+ (stop #~(make-kill-destructor)))))))
+
+(define %tailon-accounts
+ (list (user-group (name "tailon") (system? #t))
+ (user-account
+ (name "tailon")
+ (group "tailon")
+ (system? #t)
+ (comment "tailon")
+ (home-directory "/var/empty")
+ (shell (file-append shadow "/sbin/nologin")))))
+
+(define tailon-service-type
+ (service-type
+ (name 'tailon)
+ (extensions
+ (list (service-extension shepherd-root-service-type
+ tailon-shepherd-service)
+ (service-extension account-service-type
+ (const %tailon-accounts))))
+ (compose concatenate)
+ (extend (lambda (parameter files)
+ (tailon-configuration
+ (inherit parameter)
+ (config-file
+ (let ((old-config-file
+ (tailon-configuration-config-file parameter)))
+ (tailon-configuration-file
+ (inherit old-config-file)
+ (files (append (tailon-configuration-file-files old-config-file)
+ files))))))))
+ (default-value (tailon-configuration))))
+
;;; admin.scm ends here
--
2.13.1
Christopher Baines wrote 8 years ago
[PATCH] tests: Add 'tailon-service-type' test.
(address . 27650@debbugs.gnu.org)
20170716155815.14496-1-mail@cbaines.net
* gnu/local.mk (GNU_SYSTEM_MODULES): Add it.
* gnu/tests/web.scm: New file.
---
gnu/local.mk | 1 +
gnu/tests/admin.scm | 96 +++++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 97 insertions(+)
create mode 100644 gnu/tests/admin.scm

Toggle diff (116 lines)
diff --git a/gnu/local.mk b/gnu/local.mk
index 50fac3040..4bb7ce901 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -476,6 +476,7 @@ GNU_SYSTEM_MODULES = \
%D%/build/vm.scm \
\
%D%/tests.scm \
+ %D%/tests/admin.scm \
%D%/tests/base.scm \
%D%/tests/dict.scm \
%D%/tests/nfs.scm \
diff --git a/gnu/tests/admin.scm b/gnu/tests/admin.scm
new file mode 100644
index 000000000..5e2424bdb
--- /dev/null
+++ b/gnu/tests/admin.scm
@@ -0,0 +1,96 @@
+;;; GNU Guix --- Functional package management for GNU
+;;; Copyright © 2017 Christopher Baines <mail@cbaines.net>
+;;;
+;;; This file is part of GNU Guix.
+;;;
+;;; GNU Guix is free software; you can redistribute it and/or modify it
+;;; under the terms of the GNU General Public License as published by
+;;; the Free Software Foundation; either version 3 of the License, or (at
+;;; your option) any later version.
+;;;
+;;; GNU Guix is distributed in the hope that it will be useful, but
+;;; WITHOUT ANY WARRANTY; without even the implied warranty of
+;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+;;; GNU General Public License for more details.
+;;;
+;;; You should have received a copy of the GNU General Public License
+;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
+
+(define-module (gnu tests admin)
+ #:use-module (gnu tests)
+ #:use-module (gnu system)
+ #:use-module (gnu system file-systems)
+ #:use-module (gnu system shadow)
+ #:use-module (gnu system vm)
+ #:use-module (gnu services)
+ #:use-module (gnu services admin)
+ #:use-module (gnu services networking)
+ #:use-module (guix gexp)
+ #:use-module (guix store)
+ #:use-module (guix monads)
+ #:export (%test-tailon))
+
+(define %tailon-os
+ ;; Operating system under test.
+ (simple-operating-system
+ (dhcp-client-service)
+ (service tailon-service-type)))
+
+(define* (run-tailon-test #:optional (http-port 8042))
+ "Run tests in %TAILON-OS, which has tailon running and listening on
+HTTP-PORT."
+ (mlet* %store-monad ((os -> (marionette-operating-system
+ %tailon-os
+ #:imported-modules '((gnu services herd)
+ (guix combinators))))
+ (command (system-qemu-image/shared-store-script
+ os #:graphic? #f)))
+ (define test
+ (with-imported-modules '((gnu build marionette))
+ #~(begin
+ (use-modules (srfi srfi-11) (srfi srfi-64)
+ (gnu build marionette)
+ (web uri)
+ (web client)
+ (web response))
+
+ (define marionette
+ ;; Forward the guest's HTTP-PORT, where tailon is listening, to
+ ;; port 8080 in the host.
+ (make-marionette (list #$command "-net"
+ (string-append
+ "user,hostfwd=tcp::8080-:"
+ #$(number->string http-port)))))
+
+ (mkdir #$output)
+ (chdir #$output)
+
+ (test-begin "tailon")
+
+ ;; Wait for tailon to be up and running.
+ (test-eq "service running"
+ 'running!
+ (marionette-eval
+ '(begin
+ (use-modules (gnu services herd))
+ (start-service 'tailon)
+ 'running!)
+ marionette))
+
+ (test-equal "http-get"
+ 200
+ (let-values (((response text)
+ (http-get "http://localhost:8080/"
+ #:decode-body? #t)))
+ (response-code response)))
+
+ (test-end)
+ (exit (= (test-runner-fail-count (test-runner-current)) 0)))))
+
+ (gexp->derivation "tailon-test" test)))
+
+(define %test-tailon
+ (system-test
+ (name "tailon")
+ (description "Connect to a running Tailon server.")
+ (value (run-tailon-test))))
--
2.13.1
Ludovic Courtès wrote 8 years ago
Re: [bug#27650] [PATCH] gnu: services: admin: Add tailon.
(name . Christopher Baines)(address . mail@cbaines.net)(address . 27650@debbugs.gnu.org)
87mv83e9sk.fsf@gnu.org
Christopher Baines <mail@cbaines.net> skribis:

Toggle quote (2 lines)
> On Wed, 12 Jul 2017 14:13:25 +0200

[...]

Toggle quote (8 lines)
>> Bonus points if you write a system test that checks that at least the
>> Web server shows up on port 8080.
>
> I've had a go at this, I'll send a separate patch. It doesn't pass for
> me yet, and I'm not sure how to work out what is going on inside the
> test system, does anyone have any tips for writing and debugging system
> tests in general?

No specific tips. Beware of QEMU port forwarding: it doesn’t allow you
to really diagnose what’s going on if you can’t connect from the host to
the guest (it’s hard to tell if that’s because the service in the guest
is not running.) So on a few occasions I found that I’d first try
connecting from within the guest as my first attempt (using
‘marionette-eval’), to see if this would work at all.

Sometimes you’ll also want to just run a VM of the system under test
interactively so experiment a bit.

HTH,
Ludo’.
Ludovic Courtès wrote 8 years ago
(name . Christopher Baines)(address . mail@cbaines.net)(address . 27650@debbugs.gnu.org)
87r2xfbdae.fsf@gnu.org
Christopher Baines <mail@cbaines.net> skribis:

Toggle quote (7 lines)
> * gnu/services/admin.scm
> (<tailon-configuration>, <tailon-configuration-file>): New record types.
> (tailon-configuration-files-string, tailon-shepherd-service): New
> procedures.
> (%tailon-accounts, tailon-service-type: New variables.
> * doc/guix.texi (Monitoring Services: Document the Tailon service.

[...]

Toggle quote (9 lines)
> +@deftp {Data Type} tailon-configuration-file
> +Data type representing the configuration options for Tailon.
> +This type has the following parameters:
> +
> +@table @asis
> +@item @code{files} (default: @code{(list "/var/log")})
> +List of files to display. The list can include strings for a single
> +file, or a list, where the first item is the name of a subsection, and

s/file/file or directory/ (I assume it recurses into directories?)

Toggle quote (3 lines)
> +@item @code{relative-root-path} (default: @code{#f})
> +Prefix to use for all paths, set to @code{#f} to disable using a prefix.

s/path/directory/ :-)

OK to push with these changes, thank you!

Ludo’.
Ludovic Courtès wrote 8 years ago
Re: [bug#27650] [PATCH] tests: Add 'tailon-service-type' test.
(name . Christopher Baines)(address . mail@cbaines.net)(address . 27650@debbugs.gnu.org)
87mv83bd9g.fsf@gnu.org
Christopher Baines <mail@cbaines.net> skribis:

Toggle quote (3 lines)
> * gnu/local.mk (GNU_SYSTEM_MODULES): Add it.
> * gnu/tests/web.scm: New file.

Nice! LGTM, thank you!

Ludo’.
Christopher Baines wrote 8 years ago
[PATCH 1/2] gnu: services: admin: Add tailon.
(address . 27650@debbugs.gnu.org)
20170726090853.8987-1-mail@cbaines.net
* gnu/services/admin.scm
(<tailon-configuration>, <tailon-configuration-file>): New record types.
(tailon-configuration-files-string, tailon-shepherd-service): New
procedures.
(%tailon-accounts, tailon-service-type: New variables.
* doc/guix.texi (Monitoring Services: Document the Tailon service.
---
doc/guix.texi | 90 +++++++++++++++++++++++++++++
gnu/services/admin.scm | 151 ++++++++++++++++++++++++++++++++++++++++++++++++-
2 files changed, 240 insertions(+), 1 deletion(-)

Toggle diff (299 lines)
diff --git a/doc/guix.texi b/doc/guix.texi
index e8c4e0eaf..345285031 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -219,6 +219,7 @@ Services
* Database Services:: SQL databases.
* Mail Services:: IMAP, POP3, SMTP, and all that.
* Messaging Services:: Messaging services.
+* Monitoring Services:: Monitoring services.
* Kerberos Services:: Kerberos services.
* Web Services:: Web servers.
* DNS Services:: DNS daemons.
@@ -9011,6 +9012,7 @@ declaration.
* Database Services:: SQL databases.
* Mail Services:: IMAP, POP3, SMTP, and all that.
* Messaging Services:: Messaging services.
+* Monitoring Services:: Monitoring services.
* Kerberos Services:: Kerberos services.
* Web Services:: Web servers.
* DNS Services:: DNS daemons.
@@ -13599,6 +13601,94 @@ string, you could instantiate a prosody service like this:
(prosody.cfg.lua "")))
@end example
+@node Monitoring Services
+@subsubsection Monitoring Services
+
+@subsubheading Tailon Service
+
+@uref{https://tailon.readthedocs.io/, Tailon} is a web application for
+viewing and searching log files.
+
+The following example will configure the service with default values.
+By default, Tailon can be accessed on port 8080 (@code{http://localhost:8080}).
+
+@example
+(service tailon-service-type)
+@end example
+
+The following example customises more of the Tailon configuration,
+adding @command{sed} to the list of allowed commands.
+
+@example
+(service tailon-service-type
+ (tailon-configuration
+ (config-file
+ (tailon-configuration-file
+ (allowed-commands '("tail" "grep" "awk" "sed"))))))
+@end example
+
+
+@deftp {Data Type} tailon-configuration
+Data type representing the configuration of Tailon.
+This type has the following parameters:
+
+@table @asis
+@item @code{config-file} (default: @code{(tailon-configuration-file)})
+The configuration file to use for Tailon. This can be set to a
+@dfn{tailon-configuration-file} record value, or any gexp
+(@pxref{G-Expressions}).
+
+For example, to instead use a local file, the @code{local-file} function
+can be used:
+
+@example
+(service tailon-service-type
+ (tailon-configuration
+ (config-file (local-file "./my-tailon.conf"))))
+@end example
+
+@item @code{package} (default: @code{tailon})
+The tailon package to use.
+
+@end table
+@end deftp
+
+@deftp {Data Type} tailon-configuration-file
+Data type representing the configuration options for Tailon.
+This type has the following parameters:
+
+@table @asis
+@item @code{files} (default: @code{(list "/var/log")})
+List of files to display. The list can include strings for a single file
+or directory, or a list, where the first item is the name of a
+subsection, and the remaining items are the files or directories in that
+subsection.
+
+@item @code{bind} (default: @code{"localhost:8080"})
+Address and port to which Tailon should bind on.
+
+@item @code{relative-root} (default: @code{#f})
+URL path to use for Tailon, set to @code{#f} to not use a path.
+
+@item @code{allow-transfers?} (default: @code{#t})
+Allow downloading the log files in the web interface.
+
+@item @code{follow-names?} (default: @code{#t})
+Allow tailing of not-yet existent files.
+
+@item @code{tail-lines} (default: @code{200})
+Number of lines to read initially from each file.
+
+@item @code{allowed-commands} (default: @code{(list "tail" "grep" "awk")})
+Commands to allow running. By default, @code{sed} is disabled.
+
+@item @code{debug?} (default: @code{#f})
+Set @code{debug?} to @code{#t} to show debug messages.
+
+@end table
+@end deftp
+
+
@node Kerberos Services
@subsubsection Kerberos Services
@cindex Kerberos
diff --git a/gnu/services/admin.scm b/gnu/services/admin.scm
index b9e3fa70a..1044833fe 100644
--- a/gnu/services/admin.scm
+++ b/gnu/services/admin.scm
@@ -20,14 +20,19 @@
(define-module (gnu services admin)
#:use-module (gnu packages admin)
#:use-module (gnu packages base)
+ #:use-module (gnu packages logging)
#:use-module (gnu services)
#:use-module (gnu services mcron)
#:use-module (gnu services shepherd)
+ #:use-module (gnu services web)
+ #:use-module (gnu system shadow)
#:use-module (guix gexp)
+ #:use-module (guix store)
#:use-module (guix packages)
#:use-module (guix records)
#:use-module (srfi srfi-1)
#:use-module (ice-9 vlist)
+ #:use-module (ice-9 match)
#:export (%default-rotations
%rotated-files
@@ -41,7 +46,27 @@
rottlog-configuration
rottlog-configuration?
rottlog-service
- rottlog-service-type))
+ rottlog-service-type
+
+ <tailon-configuration-file>
+ tailon-configuration-file
+ tailon-configuration-file?
+ tailon-configuration-file-files
+ tailon-configuration-file-bind
+ tailon-configuration-file-relative-root
+ tailon-configuration-file-allow-transfers?
+ tailon-configuration-file-follow-names?
+ tailon-configuration-file-tail-lines
+ tailon-configuration-file-allowed-commands
+ tailon-configuration-file-debug?
+
+ <tailon-configuration>
+ tailon-configuration
+ tailon-configuration?
+ tailon-configuration-config-file
+ tailon-configuration-package
+
+ tailon-service-type))
;;; Commentary:
;;;
@@ -172,4 +197,128 @@ for ROTATION."
rotations)))))
(default-value (rottlog-configuration))))
+
+;;;
+;;; Tailon
+;;;
+
+(define-record-type* <tailon-configuration-file>
+ tailon-configuration-file make-tailon-configuration-file
+ tailon-configuration-file?
+ (files tailon-configuration-file-files
+ (default '("/var/log")))
+ (bind tailon-configuration-file-bind
+ (default "localhost:8080"))
+ (relative-root tailon-configuration-file-relative-root
+ (default #f))
+ (allow-transfers? tailon-configuration-file-allow-transfers?
+ (default #t))
+ (follow-names? tailon-configuration-file-follow-names?
+ (default #t))
+ (tail-lines tailon-configuration-file-tail-lines
+ (default 200))
+ (allowed-commands tailon-configuration-file-allowed-commands
+ (default '("tail" "grep" "awk")))
+ (debug? tailon-configuration-file-debug?
+ (default #f)))
+
+(define (tailon-configuration-files-string files)
+ (string-append
+ "\n"
+ (string-join
+ (map
+ (lambda (x)
+ (string-append
+ " - "
+ (cond
+ ((string? x)
+ (simple-format #f "'~A'" x))
+ ((list? x)
+ (string-join
+ (cons (simple-format #f "'~A':" (car x))
+ (map
+ (lambda (x) (simple-format #f " - '~A'" x))
+ (cdr x)))
+ "\n"))
+ (else (error x)))))
+ files)
+ "\n")))
+
+(define-gexp-compiler (tailon-configuration-file-compiler
+ (file <tailon-configuration-file>) system target)
+ (match file
+ (($ <tailon-configuration-file> files bind relative-root
+ allow-transfers? follow-names?
+ tail-lines allowed-commands debug?)
+ (text-file
+ "tailon-config.yaml"
+ (string-concatenate
+ (filter-map
+ (match-lambda
+ ((key . #f) #f)
+ ((key . value) (string-append key ": " value "\n")))
+
+ `(("files" . ,(tailon-configuration-files-string files))
+ ("bind" . ,bind)
+ ("relative-root" . ,relative-root)
+ ("allow-transfers" . ,(if allow-transfers? "true" "false"))
+ ("follow-names" . ,(if follow-names? "true" "false"))
+ ("tail-lines" . ,(number->string tail-lines))
+ ("commands" . ,(string-append "["
+ (string-join allowed-commands ", ")
+ "]"))
+ ,@(if debug? '(("debug" . "true")) '()))))))))
+
+(define-record-type* <tailon-configuration>
+ tailon-configuration make-tailon-configuration
+ tailon-configuration?
+ (config-file tailon-configuration-config-file
+ (default (tailon-configuration-file)))
+ (package tailon-configuration-package
+ (default tailon)))
+
+(define tailon-shepherd-service
+ (match-lambda
+ (($ <tailon-configuration> config-file package)
+ (list (shepherd-service
+ (provision '(tailon))
+ (documentation "Run the tailon daemon.")
+ (start #~(make-forkexec-constructor
+ `(,(string-append #$package "/bin/tailon")
+ "-c" ,#$config-file)
+ #:user "tailon"
+ #:group "tailon"))
+ (stop #~(make-kill-destructor)))))))
+
+(define %tailon-accounts
+ (list (user-group (name "tailon") (system? #t))
+ (user-account
+ (name "tailon")
+ (group "tailon")
+ (system? #t)
+ (comment "tailon")
+ (home-directory "/var/empty")
+ (shell (file-append shadow "/sbin/nologin")))))
+
+(define tailon-service-type
+ (service-type
+ (name 'tailon)
+ (extensions
+ (list (service-extension shepherd-root-service-type
+ tailon-shepherd-service)
+ (service-extension account-service-type
+ (const %tailon-accounts))))
+ (compose concatenate)
+ (extend (lambda (parameter files)
+ (tailon-configuration
+ (inherit parameter)
+ (config-file
+ (let ((old-config-file
+ (tailon-configuration-config-file parameter)))
+ (tailon-configuration-file
+ (inherit old-config-file)
+ (files (append (tailon-configuration-file-files old-config-file)
+ files))))))))
+ (default-value (tailon-configuration))))
+
;;; admin.scm ends here
--
2.13.3
Christopher Baines wrote 8 years ago
[PATCH 2/2] tests: Add 'tailon-service-type' test.
(address . 27650@debbugs.gnu.org)
20170726090853.8987-2-mail@cbaines.net
* gnu/local.mk (GNU_SYSTEM_MODULES): Add it.
* gnu/tests/web.scm: New file.
---
gnu/local.mk | 1 +
gnu/tests/admin.scm | 106 ++++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 107 insertions(+)
create mode 100644 gnu/tests/admin.scm

Toggle diff (126 lines)
diff --git a/gnu/local.mk b/gnu/local.mk
index 9dfca9dbb..90dfcfeb5 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -479,6 +479,7 @@ GNU_SYSTEM_MODULES = \
%D%/build/vm.scm \
\
%D%/tests.scm \
+ %D%/tests/admin.scm \
%D%/tests/base.scm \
%D%/tests/dict.scm \
%D%/tests/nfs.scm \
diff --git a/gnu/tests/admin.scm b/gnu/tests/admin.scm
new file mode 100644
index 000000000..06373be14
--- /dev/null
+++ b/gnu/tests/admin.scm
@@ -0,0 +1,106 @@
+;;; GNU Guix --- Functional package management for GNU
+;;; Copyright © 2017 Christopher Baines <mail@cbaines.net>
+;;;
+;;; This file is part of GNU Guix.
+;;;
+;;; GNU Guix is free software; you can redistribute it and/or modify it
+;;; under the terms of the GNU General Public License as published by
+;;; the Free Software Foundation; either version 3 of the License, or (at
+;;; your option) any later version.
+;;;
+;;; GNU Guix is distributed in the hope that it will be useful, but
+;;; WITHOUT ANY WARRANTY; without even the implied warranty of
+;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+;;; GNU General Public License for more details.
+;;;
+;;; You should have received a copy of the GNU General Public License
+;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
+
+(define-module (gnu tests admin)
+ #:use-module (gnu tests)
+ #:use-module (gnu system)
+ #:use-module (gnu system file-systems)
+ #:use-module (gnu system shadow)
+ #:use-module (gnu system vm)
+ #:use-module (gnu services)
+ #:use-module (gnu services admin)
+ #:use-module (gnu services networking)
+ #:use-module (guix gexp)
+ #:use-module (guix store)
+ #:use-module (guix monads)
+ #:export (%test-tailon))
+
+(define %tailon-os
+ ;; Operating system under test.
+ (simple-operating-system
+ (dhcp-client-service)
+ (service tailon-service-type
+ (tailon-configuration
+ (config-file
+ (tailon-configuration-file
+ (bind "0.0.0.0:8080")))))))
+
+(define* (run-tailon-test #:optional (http-port 8081))
+ "Run tests in %TAILON-OS, which has tailon running and listening on
+HTTP-PORT."
+ (mlet* %store-monad ((os -> (marionette-operating-system
+ %tailon-os
+ #:imported-modules '((gnu services herd)
+ (guix combinators))))
+ (command (system-qemu-image/shared-store-script
+ os #:graphic? #f)))
+ (define test
+ (with-imported-modules '((gnu build marionette))
+ #~(begin
+ (use-modules (srfi srfi-11) (srfi srfi-64)
+ (gnu build marionette)
+ (web uri)
+ (web client)
+ (web response))
+
+ (define marionette
+ ;; Forward the guest's HTTP-PORT, where tailon is listening, to
+ ;; port 8080 in the host.
+ (make-marionette (list #$command "-net"
+ #$(simple-format
+ #f
+ "user,hostfwd=tcp::~A-:8080"
+ http-port))))
+
+ (mkdir #$output)
+ (chdir #$output)
+
+ (test-begin "tailon")
+
+ (test-eq "service running"
+ 'running!
+ (marionette-eval
+ '(begin
+ (use-modules (gnu services herd))
+ (start-service 'tailon)
+ 'running!)
+ marionette))
+
+ ;; Wait for tailon to be up and running.
+ (sleep 5)
+
+ (test-equal "http-get"
+ 200
+ (let-values (((response text)
+ (http-get #$(simple-format
+ #f
+ "http://localhost:~A/"
+ http-port)
+ #:decode-body? #t)))
+ (response-code response)))
+
+ (test-end)
+ (exit (= (test-runner-fail-count (test-runner-current)) 0)))))
+
+ (gexp->derivation "tailon-test" test)))
+
+(define %test-tailon
+ (system-test
+ (name "tailon")
+ (description "Connect to a running Tailon server.")
+ (value (run-tailon-test))))
--
2.13.3
Christopher Baines wrote 8 years ago
Re: [bug#27650] [PATCH] gnu: services: admin: Add tailon.
(name . Ludovic Courtès)(address . ludo@gnu.org)(address . 27650@debbugs.gnu.org)
20170726105009.14461c68@cbaines.net
On Mon, 17 Jul 2017 11:52:57 +0200
ludo@gnu.org (Ludovic Courtès) wrote:

Toggle quote (23 lines)
> Christopher Baines <mail@cbaines.net> skribis:
>
> > * gnu/services/admin.scm
> > (<tailon-configuration>, <tailon-configuration-file>): New record
> > types. (tailon-configuration-files-string,
> > tailon-shepherd-service): New procedures.
> > (%tailon-accounts, tailon-service-type: New variables.
> > * doc/guix.texi (Monitoring Services: Document the Tailon service.
>
> [...]
>
> > +@deftp {Data Type} tailon-configuration-file
> > +Data type representing the configuration options for Tailon.
> > +This type has the following parameters:
> > +
> > +@table @asis
> > +@item @code{files} (default: @code{(list "/var/log")})
> > +List of files to display. The list can include strings for a single
> > +file, or a list, where the first item is the name of a subsection,
> > and
>
> s/file/file or directory/ (I assume it recurses into directories?)

Yep, it shows the files in the directory. I've sent an updated patch
with this change.

Toggle quote (6 lines)
> > +@item @code{relative-root-path} (default: @code{#f})
> > +Prefix to use for all paths, set to @code{#f} to disable using a
> > prefix.
>
> s/path/directory/ :-)

So, it turns out I'd completely misinterpreted this option, I was
thinking it was about the log files, as in you would set it to /var/log
if you wanted to specify filenames relative to there. That is wrong,
its actually about the URL path, so if you want to have Tailon at
http://localhost/tailon/you set the relative-root to /tailon/. I've
now updated the code and docs for this.

Toggle quote (2 lines)
> OK to push with these changes, thank you!

I've sent the two patches again. I also was able to debug the issue I
was having with the system test, I needed to get Tailon to bind to
0.0.0.0, rather than localhost for it to work, and with that change,
the system test works!
-----BEGIN PGP SIGNATURE-----

iQKTBAEBCgB9FiEEPonu50WOcg2XVOCyXiijOwuE9XcFAll4ZdFfFIAAAAAALgAo
aXNzdWVyLWZwckBub3RhdGlvbnMub3BlbnBncC5maWZ0aGhvcnNlbWFuLm5ldDNF
ODlFRUU3NDU4RTcyMEQ5NzU0RTBCMjVFMjhBMzNCMEI4NEY1NzcACgkQXiijOwuE
9Xf/HQ//e0dQ30tMHAE7abkYoDB62uFOaDLbn2UFFf982Ho7V5/7Enq76eejZwuw
7PiXfnRK97L6COq/QZpd3N/tBYjjvbz07P9bFhAmNU01TWzX9CyJMVkE9defMnlA
V3B/HGallzOlWVoMuYwbiR1NYEnPphpXTps/D/bQPTELjm8mXnnGrUUopYy/ns+h
P6+dSg/Qe655waAIwnXrxN51QK5zcnCyi793drKbwpN7yXmLGBOgnvBj0urczJ+e
xoDlJAPqR7eZ+paT69aLFMnZ5oHA5VB8sY07gUEARQJxJNofDmMRvma1pPPqr+5U
ghffTX463CHLFYiWeOix+PG410XFp6vjKsXe/N36jpUWHPH2HC61lzbmwKSve7lP
2ocATREHwHv8dgkTByo5ib3tYOjn0Xl9z80IwwmCq1iZkkl7mUstIfY0dC8KD8lL
brdCDi02qX4HzyBwAhqCcs75s1vmSBoDBqTEO9iHyFjR2vFkdILdOoOn5Xb1Jo4b
cudGhsxm6M7Kqz0Dcvuh2uu6bWCUo9fFnyukaRPttS/6ntn9GbpcFDyIZRjhSxkz
NiRZFE/KZxGXOkFnz9GIoPUSTJJ9i0cJtbP0GY+mTyvzP6B8Zt6YP4G2ji660W1n
24GqXX+D7e7ghUjcFpG11LKg41xc6VbjXtuNiHpiP/AMWwjDjjg=
=miH8
-----END PGP SIGNATURE-----


Ludovic Courtès wrote 8 years ago
Re: [bug#27650] [PATCH 1/2] gnu: services: admin: Add tailon.
(name . Christopher Baines)(address . mail@cbaines.net)(address . 27650@debbugs.gnu.org)
878tjb7wyy.fsf@gnu.org
Christopher Baines <mail@cbaines.net> skribis:

Toggle quote (7 lines)
> * gnu/services/admin.scm
> (<tailon-configuration>, <tailon-configuration-file>): New record types.
> (tailon-configuration-files-string, tailon-shepherd-service): New
> procedures.
> (%tailon-accounts, tailon-service-type: New variables.
> * doc/guix.texi (Monitoring Services: Document the Tailon service.

LGTM!
Ludovic Courtès wrote 8 years ago
Re: [bug#27650] [PATCH 2/2] tests: Add 'tailon-service-type' test.
(name . Christopher Baines)(address . mail@cbaines.net)(address . 27650@debbugs.gnu.org)
87379j7wpe.fsf@gnu.org
Christopher Baines <mail@cbaines.net> skribis:

Toggle quote (3 lines)
> * gnu/local.mk (GNU_SYSTEM_MODULES): Add it.
> * gnu/tests/web.scm: New file.

[...]

Toggle quote (11 lines)
> +(define* (run-tailon-test #:optional (http-port 8081))
> + "Run tests in %TAILON-OS, which has tailon running and listening on
> +HTTP-PORT."
> + (mlet* %store-monad ((os -> (marionette-operating-system
> + %tailon-os
> + #:imported-modules '((gnu services herd)
> + (guix combinators))))
> + (command (system-qemu-image/shared-store-script
> + os #:graphic? #f)))


[...]

Toggle quote (9 lines)
> + (define marionette
> + ;; Forward the guest's HTTP-PORT, where tailon is listening, to
> + ;; port 8080 in the host.
> + (make-marionette (list #$command "-net"
> + #$(simple-format
> + #f
> + "user,hostfwd=tcp::~A-:8080"
> + http-port))))

This can be simplified using the new ‘virtual-machine’ objects:


Could you give it a try?

Toggle quote (10 lines)
> + (test-equal "http-get"
> + 200
> + (let-values (((response text)
> + (http-get #$(simple-format
> + #f
> + "http://localhost:~A/"
> + http-port)
> + #:decode-body? #t)))
> + (response-code response)))

If there was a more specific API, like a rest API to check whether a
specific log file exists, perhaps that’d be a good extra test.
Otherwise that’s fine.

BTW, it’s enough to use ‘format’ rather than ‘simple-format’ here: it’s
(roughly) equivalent and incurs less typing. :-)

Feel free to squeeze this patch with the previous one (thus making a
self-contained commit), or leave it separately if it’s more convenient
for you.

Thanks for taking the time to write this test!

Ludo’.
Christopher Baines wrote 8 years ago
(name . Ludovic Courtès)(address . ludo@gnu.org)(address . 27650@debbugs.gnu.org)
20170727183326.23045a4a@cbaines.net
On Wed, 26 Jul 2017 22:46:37 +0200
ludo@gnu.org (Ludovic Courtès) wrote:

Toggle quote (40 lines)
> Christopher Baines <mail@cbaines.net> skribis:
>
> > * gnu/local.mk (GNU_SYSTEM_MODULES): Add it.
> > * gnu/tests/web.scm: New file.
>
> [...]
>
> > +(define* (run-tailon-test #:optional (http-port 8081))
> > + "Run tests in %TAILON-OS, which has tailon running and listening
> > on +HTTP-PORT."
> > + (mlet* %store-monad ((os -> (marionette-operating-system
> > + %tailon-os
> > + #:imported-modules '((gnu
> > services herd)
> > + (guix
> > combinators))))
> > + (command
> > (system-qemu-image/shared-store-script
> > + os #:graphic? #f)))
>
>
> [...]
>
> > + (define marionette
> > + ;; Forward the guest's HTTP-PORT, where tailon is
> > listening, to
> > + ;; port 8080 in the host.
> > + (make-marionette (list #$command "-net"
> > + #$(simple-format
> > + #f
> > +
> > "user,hostfwd=tcp::~A-:8080"
> > + http-port))))
>
> This can be simplified using the new ‘virtual-machine’ objects:
>
> https://debbugs.gnu.org/cgi/bugreport.cgi?bug=27751
>
> Could you give it a try?

Yep, I'll send an updated patch that switches to use this approach.

Toggle quote (14 lines)
> > + (test-equal "http-get"
> > + 200
> > + (let-values (((response text)
> > + (http-get #$(simple-format
> > + #f
> > + "http://localhost:~A/"
> > + http-port)
> > + #:decode-body? #t)))
> > + (response-code response)))
>
> If there was a more specific API, like a rest API to check whether a
> specific log file exists, perhaps that’d be a good extra test.
> Otherwise that’s fine.

I'm not sure there is an API, but I'll have a think about more useful
testing approaches. Maybe checking for things in the response, or
trying to run Tailon's test suite...

Toggle quote (3 lines)
> BTW, it’s enough to use ‘format’ rather than ‘simple-format’ here:
> it’s (roughly) equivalent and incurs less typing. :-)

Ok, I'll change to use format.

Toggle quote (4 lines)
> Feel free to squeeze this patch with the previous one (thus making a
> self-contained commit), or leave it separately if it’s more convenient
> for you.

Squashing them is fine, I'll do this.

Toggle quote (2 lines)
> Thanks for taking the time to write this test!

No problem, thanks for your and everyone elses advice on QEMU on IRC,
it was very useful.

Also, I've removed the sleep, and replaced it with a function to retry
the connection on error, which should hopefully avoid any issues with
it failing just because Tailon hasn't finished starting yet.
-----BEGIN PGP SIGNATURE-----

iQKTBAEBCgB9FiEEPonu50WOcg2XVOCyXiijOwuE9XcFAll6I+ZfFIAAAAAALgAo
aXNzdWVyLWZwckBub3RhdGlvbnMub3BlbnBncC5maWZ0aGhvcnNlbWFuLm5ldDNF
ODlFRUU3NDU4RTcyMEQ5NzU0RTBCMjVFMjhBMzNCMEI4NEY1NzcACgkQXiijOwuE
9XdKRA//YSvaIIdmWGJLxV4HsyPDHKDUADMAh3qEWryFjJBiAoYYDyecpiLqRLLq
Rr7HvnnEffx6JAUIDb3Rm5y/mGg+v7VYYWFCIDWnwO9s8yjd8FXLZJNx3Ft/nrY1
SQapJpt3CdlQTZubSb8f4vQxGG23uMyvm8MET94UxXyRFnKuClfEDTHpu9D2nGJo
KPZEWwb5qhIx7kXxs3imoRkO/a1hffXhqdV9l/u5oUTDykor+B4tANUB7WBRoZpK
8KM1e2Jk02W34glDVsUD5Z0VI6/36ZItkXby8VdhFbDrlK+cVoiY6nSBvSq/FYG3
mUfX7wMBZAGdTWj5vDEb5JRY+R4mE6gNsbLpGHX3k6W43u47K+ZkYUjOHO8v/JMe
GOTqlYH1D3jLZecgcLD7XjBH22CYxRItgMuuxrESMEuEoAwACuyj+ar/r9jwG+j/
PlCJ6xMxEkgTC7++wTxNIRDc8Z+9u9DLB8tjujKeGlVTT6GPSFSKQOvO3SE+BqVm
UWWmxNCH6iKmfulOMy2xFr+GaYWhvIB/uir7Jzxv09S+JuppNSrCUw0dYi4sN3Ci
yZwfLa/wmmguNuL0X1u7BT+ANms42RlkWISacO2ap7/p08NFZW1URVjwiDMo6D2j
m1+Gqf9aohdZMqRPBml4NcuhwCoyxGwJ1j1OVF1LpOlpyXQSzlk=
=9791
-----END PGP SIGNATURE-----


Christopher Baines wrote 8 years ago
[PATCH] gnu: services: admin: Add tailon.
(address . 27650@debbugs.gnu.org)
20170727173506.23641-1-mail@cbaines.net
* gnu/services/admin.scm
(<tailon-configuration>, <tailon-configuration-file>): New record types.
(tailon-configuration-files-string, tailon-shepherd-service): New
procedures.
(%tailon-accounts, tailon-service-type: New variables.
* doc/guix.texi (Monitoring Services: Document the Tailon service.
* gnu/local.mk (GNU_SYSTEM_MODULES): Add it.
* gnu/tests/admin.scm: New file.
---
doc/guix.texi | 90 +++++++++++++++++++++++++++++
gnu/local.mk | 1 +
gnu/services/admin.scm | 151 ++++++++++++++++++++++++++++++++++++++++++++++++-
gnu/tests/admin.scm | 128 +++++++++++++++++++++++++++++++++++++++++
4 files changed, 369 insertions(+), 1 deletion(-)
create mode 100644 gnu/tests/admin.scm

Toggle diff (445 lines)
diff --git a/doc/guix.texi b/doc/guix.texi
index e8c4e0eaf..345285031 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -219,6 +219,7 @@ Services
* Database Services:: SQL databases.
* Mail Services:: IMAP, POP3, SMTP, and all that.
* Messaging Services:: Messaging services.
+* Monitoring Services:: Monitoring services.
* Kerberos Services:: Kerberos services.
* Web Services:: Web servers.
* DNS Services:: DNS daemons.
@@ -9011,6 +9012,7 @@ declaration.
* Database Services:: SQL databases.
* Mail Services:: IMAP, POP3, SMTP, and all that.
* Messaging Services:: Messaging services.
+* Monitoring Services:: Monitoring services.
* Kerberos Services:: Kerberos services.
* Web Services:: Web servers.
* DNS Services:: DNS daemons.
@@ -13599,6 +13601,94 @@ string, you could instantiate a prosody service like this:
(prosody.cfg.lua "")))
@end example
+@node Monitoring Services
+@subsubsection Monitoring Services
+
+@subsubheading Tailon Service
+
+@uref{https://tailon.readthedocs.io/, Tailon} is a web application for
+viewing and searching log files.
+
+The following example will configure the service with default values.
+By default, Tailon can be accessed on port 8080 (@code{http://localhost:8080}).
+
+@example
+(service tailon-service-type)
+@end example
+
+The following example customises more of the Tailon configuration,
+adding @command{sed} to the list of allowed commands.
+
+@example
+(service tailon-service-type
+ (tailon-configuration
+ (config-file
+ (tailon-configuration-file
+ (allowed-commands '("tail" "grep" "awk" "sed"))))))
+@end example
+
+
+@deftp {Data Type} tailon-configuration
+Data type representing the configuration of Tailon.
+This type has the following parameters:
+
+@table @asis
+@item @code{config-file} (default: @code{(tailon-configuration-file)})
+The configuration file to use for Tailon. This can be set to a
+@dfn{tailon-configuration-file} record value, or any gexp
+(@pxref{G-Expressions}).
+
+For example, to instead use a local file, the @code{local-file} function
+can be used:
+
+@example
+(service tailon-service-type
+ (tailon-configuration
+ (config-file (local-file "./my-tailon.conf"))))
+@end example
+
+@item @code{package} (default: @code{tailon})
+The tailon package to use.
+
+@end table
+@end deftp
+
+@deftp {Data Type} tailon-configuration-file
+Data type representing the configuration options for Tailon.
+This type has the following parameters:
+
+@table @asis
+@item @code{files} (default: @code{(list "/var/log")})
+List of files to display. The list can include strings for a single file
+or directory, or a list, where the first item is the name of a
+subsection, and the remaining items are the files or directories in that
+subsection.
+
+@item @code{bind} (default: @code{"localhost:8080"})
+Address and port to which Tailon should bind on.
+
+@item @code{relative-root} (default: @code{#f})
+URL path to use for Tailon, set to @code{#f} to not use a path.
+
+@item @code{allow-transfers?} (default: @code{#t})
+Allow downloading the log files in the web interface.
+
+@item @code{follow-names?} (default: @code{#t})
+Allow tailing of not-yet existent files.
+
+@item @code{tail-lines} (default: @code{200})
+Number of lines to read initially from each file.
+
+@item @code{allowed-commands} (default: @code{(list "tail" "grep" "awk")})
+Commands to allow running. By default, @code{sed} is disabled.
+
+@item @code{debug?} (default: @code{#f})
+Set @code{debug?} to @code{#t} to show debug messages.
+
+@end table
+@end deftp
+
+
@node Kerberos Services
@subsubsection Kerberos Services
@cindex Kerberos
diff --git a/gnu/local.mk b/gnu/local.mk
index 9dfca9dbb..90dfcfeb5 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -479,6 +479,7 @@ GNU_SYSTEM_MODULES = \
%D%/build/vm.scm \
\
%D%/tests.scm \
+ %D%/tests/admin.scm \
%D%/tests/base.scm \
%D%/tests/dict.scm \
%D%/tests/nfs.scm \
diff --git a/gnu/services/admin.scm b/gnu/services/admin.scm
index b9e3fa70a..1044833fe 100644
--- a/gnu/services/admin.scm
+++ b/gnu/services/admin.scm
@@ -20,14 +20,19 @@
(define-module (gnu services admin)
#:use-module (gnu packages admin)
#:use-module (gnu packages base)
+ #:use-module (gnu packages logging)
#:use-module (gnu services)
#:use-module (gnu services mcron)
#:use-module (gnu services shepherd)
+ #:use-module (gnu services web)
+ #:use-module (gnu system shadow)
#:use-module (guix gexp)
+ #:use-module (guix store)
#:use-module (guix packages)
#:use-module (guix records)
#:use-module (srfi srfi-1)
#:use-module (ice-9 vlist)
+ #:use-module (ice-9 match)
#:export (%default-rotations
%rotated-files
@@ -41,7 +46,27 @@
rottlog-configuration
rottlog-configuration?
rottlog-service
- rottlog-service-type))
+ rottlog-service-type
+
+ <tailon-configuration-file>
+ tailon-configuration-file
+ tailon-configuration-file?
+ tailon-configuration-file-files
+ tailon-configuration-file-bind
+ tailon-configuration-file-relative-root
+ tailon-configuration-file-allow-transfers?
+ tailon-configuration-file-follow-names?
+ tailon-configuration-file-tail-lines
+ tailon-configuration-file-allowed-commands
+ tailon-configuration-file-debug?
+
+ <tailon-configuration>
+ tailon-configuration
+ tailon-configuration?
+ tailon-configuration-config-file
+ tailon-configuration-package
+
+ tailon-service-type))
;;; Commentary:
;;;
@@ -172,4 +197,128 @@ for ROTATION."
rotations)))))
(default-value (rottlog-configuration))))
+
+;;;
+;;; Tailon
+;;;
+
+(define-record-type* <tailon-configuration-file>
+ tailon-configuration-file make-tailon-configuration-file
+ tailon-configuration-file?
+ (files tailon-configuration-file-files
+ (default '("/var/log")))
+ (bind tailon-configuration-file-bind
+ (default "localhost:8080"))
+ (relative-root tailon-configuration-file-relative-root
+ (default #f))
+ (allow-transfers? tailon-configuration-file-allow-transfers?
+ (default #t))
+ (follow-names? tailon-configuration-file-follow-names?
+ (default #t))
+ (tail-lines tailon-configuration-file-tail-lines
+ (default 200))
+ (allowed-commands tailon-configuration-file-allowed-commands
+ (default '("tail" "grep" "awk")))
+ (debug? tailon-configuration-file-debug?
+ (default #f)))
+
+(define (tailon-configuration-files-string files)
+ (string-append
+ "\n"
+ (string-join
+ (map
+ (lambda (x)
+ (string-append
+ " - "
+ (cond
+ ((string? x)
+ (simple-format #f "'~A'" x))
+ ((list? x)
+ (string-join
+ (cons (simple-format #f "'~A':" (car x))
+ (map
+ (lambda (x) (simple-format #f " - '~A'" x))
+ (cdr x)))
+ "\n"))
+ (else (error x)))))
+ files)
+ "\n")))
+
+(define-gexp-compiler (tailon-configuration-file-compiler
+ (file <tailon-configuration-file>) system target)
+ (match file
+ (($ <tailon-configuration-file> files bind relative-root
+ allow-transfers? follow-names?
+ tail-lines allowed-commands debug?)
+ (text-file
+ "tailon-config.yaml"
+ (string-concatenate
+ (filter-map
+ (match-lambda
+ ((key . #f) #f)
+ ((key . value) (string-append key ": " value "\n")))
+
+ `(("files" . ,(tailon-configuration-files-string files))
+ ("bind" . ,bind)
+ ("relative-root" . ,relative-root)
+ ("allow-transfers" . ,(if allow-transfers? "true" "false"))
+ ("follow-names" . ,(if follow-names? "true" "false"))
+ ("tail-lines" . ,(number->string tail-lines))
+ ("commands" . ,(string-append "["
+ (string-join allowed-commands ", ")
+ "]"))
+ ,@(if debug? '(("debug" . "true")) '()))))))))
+
+(define-record-type* <tailon-configuration>
+ tailon-configuration make-tailon-configuration
+ tailon-configuration?
+ (config-file tailon-configuration-config-file
+ (default (tailon-configuration-file)))
+ (package tailon-configuration-package
+ (default tailon)))
+
+(define tailon-shepherd-service
+ (match-lambda
+ (($ <tailon-configuration> config-file package)
+ (list (shepherd-service
+ (provision '(tailon))
+ (documentation "Run the tailon daemon.")
+ (start #~(make-forkexec-constructor
+ `(,(string-append #$package "/bin/tailon")
+ "-c" ,#$config-file)
+ #:user "tailon"
+ #:group "tailon"))
+ (stop #~(make-kill-destructor)))))))
+
+(define %tailon-accounts
+ (list (user-group (name "tailon") (system? #t))
+ (user-account
+ (name "tailon")
+ (group "tailon")
+ (system? #t)
+ (comment "tailon")
+ (home-directory "/var/empty")
+ (shell (file-append shadow "/sbin/nologin")))))
+
+(define tailon-service-type
+ (service-type
+ (name 'tailon)
+ (extensions
+ (list (service-extension shepherd-root-service-type
+ tailon-shepherd-service)
+ (service-extension account-service-type
+ (const %tailon-accounts))))
+ (compose concatenate)
+ (extend (lambda (parameter files)
+ (tailon-configuration
+ (inherit parameter)
+ (config-file
+ (let ((old-config-file
+ (tailon-configuration-config-file parameter)))
+ (tailon-configuration-file
+ (inherit old-config-file)
+ (files (append (tailon-configuration-file-files old-config-file)
+ files))))))))
+ (default-value (tailon-configuration))))
+
;;; admin.scm ends here
diff --git a/gnu/tests/admin.scm b/gnu/tests/admin.scm
new file mode 100644
index 000000000..ef3ddf079
--- /dev/null
+++ b/gnu/tests/admin.scm
@@ -0,0 +1,128 @@
+;;; GNU Guix --- Functional package management for GNU
+;;; Copyright © 2017 Christopher Baines <mail@cbaines.net>
+;;;
+;;; This file is part of GNU Guix.
+;;;
+;;; GNU Guix is free software; you can redistribute it and/or modify it
+;;; under the terms of the GNU General Public License as published by
+;;; the Free Software Foundation; either version 3 of the License, or (at
+;;; your option) any later version.
+;;;
+;;; GNU Guix is distributed in the hope that it will be useful, but
+;;; WITHOUT ANY WARRANTY; without even the implied warranty of
+;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+;;; GNU General Public License for more details.
+;;;
+;;; You should have received a copy of the GNU General Public License
+;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
+
+(define-module (gnu tests admin)
+ #:use-module (gnu tests)
+ #:use-module (gnu system)
+ #:use-module (gnu system file-systems)
+ #:use-module (gnu system shadow)
+ #:use-module (gnu system vm)
+ #:use-module (gnu services)
+ #:use-module (gnu services admin)
+ #:use-module (gnu services networking)
+ #:use-module (guix gexp)
+ #:use-module (guix store)
+ #:use-module (guix monads)
+ #:export (%test-tailon))
+
+(define %tailon-os
+ ;; Operating system under test.
+ (simple-operating-system
+ (dhcp-client-service)
+ (service tailon-service-type
+ (tailon-configuration
+ (config-file
+ (tailon-configuration-file
+ (bind "0.0.0.0:8080")))))))
+
+(define* (run-tailon-test #:optional (http-port 8081))
+ "Run tests in %TAILON-OS, which has tailon running and listening on
+HTTP-PORT."
+ (define os
+ (marionette-operating-system
+ %tailon-os
+ #:imported-modules '((gnu services herd)
+ (guix combinators))))
+
+ (define vm
+ (virtual-machine
+ (operating-system os)
+ (port-forwardings `((,http-port . 8080)))))
+
+ (define test
+ (with-imported-modules '((gnu build marionette))
+ #~(begin
+ (use-modules (srfi srfi-11) (srfi srfi-64)
+ (ice-9 match)
+ (gnu build marionette)
+ (web uri)
+ (web client)
+ (web response))
+
+ (define marionette
+ ;; Forward the guest's HTTP-PORT, where tailon is listening, to
+ ;; port 8080 in the host.
+ (make-marionette (list #$vm)))
+
+ (mkdir #$output)
+ (chdir #$output)
+
+ (test-begin "tailon")
+
+ (test-eq "service running"
+ 'running!
+ (marionette-eval
+ '(begin
+ (use-modules (gnu services herd))
+ (start-service 'tailon)
+ 'running!)
+ marionette))
+
+ (define* (retry-on-error f #:key times delay)
+ (let loop ((attempt 1))
+ (match (catch
+ #t
+ (lambda ()
+ (cons #t
+ (f)))
+ (lambda args
+ (cons #f
+ args)))
+ ((#t . return-value)
+ return-value)
+ ((#f . error-args)
+ (if (>= attempt times)
+ error-args
+ (begin
+ (sleep delay)
+ (loop (+ 1 attempt))))))))
+
+ (test-equal "http-get"
+ 200
+ (retry-on-error
+ (lambda ()
+ (let-values (((response text)
+ (http-get #$(format
+ #f
+ "http://localhost:~A/"
+ http-port)
+ #:decode-body? #t)))
+ (response-code response)))
+ #:times 5
+ #:delay 2))
+
+ (test-end)
+ (exit (= (test-runner-fail-count (test-runner-current)) 0)))))
+
+ (gexp->derivation "tailon-test" test))
+
+(define %test-tailon
+ (system-test
+ (name "tailon")
+ (description "Connect to a running Tailon server.")
+ (value (run-tailon-test))))
--
2.13.3
Ludovic Courtès wrote 8 years ago
(name . Christopher Baines)(address . mail@cbaines.net)(address . 27650@debbugs.gnu.org)
877eysmk0l.fsf@gnu.org
Christopher Baines <mail@cbaines.net> skribis:

Toggle quote (9 lines)
> * gnu/services/admin.scm
> (<tailon-configuration>, <tailon-configuration-file>): New record types.
> (tailon-configuration-files-string, tailon-shepherd-service): New
> procedures.
> (%tailon-accounts, tailon-service-type: New variables.
> * doc/guix.texi (Monitoring Services: Document the Tailon service.
> * gnu/local.mk (GNU_SYSTEM_MODULES): Add it.
> * gnu/tests/admin.scm: New file.

You also need to add gnu/tests/admin.scm to local.mk, but apart from
that it looks perfect to me. Thank you!

Ludo’.
Christopher Baines wrote 8 years ago
(name . Ludovic Courtès)(address . ludo@gnu.org)(address . 27650@debbugs.gnu.org)
20170728220022.01ed8ee2@cbaines.net
On Fri, 28 Jul 2017 21:36:10 +0200
ludo@gnu.org (Ludovic Courtès) wrote:

Toggle quote (14 lines)
> Christopher Baines <mail@cbaines.net> skribis:
>
> > * gnu/services/admin.scm
> > (<tailon-configuration>, <tailon-configuration-file>): New record
> > types. (tailon-configuration-files-string,
> > tailon-shepherd-service): New procedures.
> > (%tailon-accounts, tailon-service-type: New variables.
> > * doc/guix.texi (Monitoring Services: Document the Tailon service.
> > * gnu/local.mk (GNU_SYSTEM_MODULES): Add it.
> > * gnu/tests/admin.scm: New file.
>
> You also need to add gnu/tests/admin.scm to local.mk, but apart from
> that it looks perfect to me. Thank you!

The latest patch I send should have included updating local.mk, at
least the quoted changelog claims to change the file. I'll clarify what
exactly was added, and look to push this, but do let me know if there
is something that still needs doing.

Thanks for your help and review,

Chris
-----BEGIN PGP SIGNATURE-----

iQKTBAEBCgB9FiEEPonu50WOcg2XVOCyXiijOwuE9XcFAll7peZfFIAAAAAALgAo
aXNzdWVyLWZwckBub3RhdGlvbnMub3BlbnBncC5maWZ0aGhvcnNlbWFuLm5ldDNF
ODlFRUU3NDU4RTcyMEQ5NzU0RTBCMjVFMjhBMzNCMEI4NEY1NzcACgkQXiijOwuE
9XfskxAAuLVFjqb5o1YlWn5pew6PbXaVOroUpO8gfC30dY0buBuOHs9j1oMSYZ9P
PnR8dQwJkfrinA1hSFGsOBPqdEh6n+jcs6hTIv0/vSNR/2g2rutHopd72cSA/pwg
2YfmpmQfQFMgmhICanpmZ7XzsueWorCF+UXGFG+kTaAd+k+2NpZJZYClHFxXsz9B
eEnPKfIEwgVLYHtNd6xx/x+PMxrgk1ZrNxD0P7gzWQQWNFhDKHDE4+LuObaUeLgn
7kLl3CDdDhoIM/fhLPhS1NV9PpAn+t3A9f9sAx2R6obCen06RR37YIMhBfyr7OwW
FwUmZkabPQ9hpA6uQhlYkB379tjGPp0mJLVjhMbpBknJBzK7iNe7EoznhLZHJcFp
8EjQ7Rai2WMEhzpB9h/4QNqXOcRfFRYNsV2KhpnihCvEAkEX4WsTnsK81xEq66P5
WF+Xm8Wb23p5CydbSVsZhOc+5VfE+RnLkef5rRJlAi9+rznIVaZfU0Haf+2h0oXL
UgCbw3Cs5JHi7REUodl/5Xv6fopaMdIZ5ZzAbb9cIaztyuap1UU+2I1ZF4fzM70p
jHFQiZ76iDlwVpgGdtUi5PjCLNeLyyrr43Dzb16h+DW59gzhrRL/npJ1kY7+D/RS
PiJ81Lp9iOEipXv1oAcTSRuqF9aaosb1RW4U3qPf5IYGXGdKLBc=
=+zPl
-----END PGP SIGNATURE-----


Christopher Baines wrote 8 years ago
(address . 27650-done@debbugs.gnu.org)
20170729130053.7621cbb6@cbaines.net
On Fri, 28 Jul 2017 22:00:22 +0100
Christopher Baines <mail@cbaines.net> wrote:

Toggle quote (22 lines)
> On Fri, 28 Jul 2017 21:36:10 +0200
> ludo@gnu.org (Ludovic Courtès) wrote:
>
> > Christopher Baines <mail@cbaines.net> skribis:
> >
> > > * gnu/services/admin.scm
> > > (<tailon-configuration>, <tailon-configuration-file>): New
> > > record types. (tailon-configuration-files-string,
> > > tailon-shepherd-service): New procedures.
> > > (%tailon-accounts, tailon-service-type: New variables.
> > > * doc/guix.texi (Monitoring Services: Document the Tailon service.
> > > * gnu/local.mk (GNU_SYSTEM_MODULES): Add it.
> > > * gnu/tests/admin.scm: New file.
> >
> > You also need to add gnu/tests/admin.scm to local.mk, but apart from
> > that it looks perfect to me. Thank you!
>
> The latest patch I send should have included updating local.mk, at
> least the quoted changelog claims to change the file. I'll clarify
> what exactly was added, and look to push this, but do let me know if
> there is something that still needs doing.

Now pushed!
-----BEGIN PGP SIGNATURE-----

iQKTBAEBCgB9FiEEPonu50WOcg2XVOCyXiijOwuE9XcFAll8ePVfFIAAAAAALgAo
aXNzdWVyLWZwckBub3RhdGlvbnMub3BlbnBncC5maWZ0aGhvcnNlbWFuLm5ldDNF
ODlFRUU3NDU4RTcyMEQ5NzU0RTBCMjVFMjhBMzNCMEI4NEY1NzcACgkQXiijOwuE
9XeiSg/+Oz+hMbMlLTdx9FfAk50Nm7HkktBHwdUIeO2Bt8Q6qGeTnI6eG612Bv0i
dmGoopHxRthhjIsl3cUPWboI26C3mAmORz2qZu5IVLcjPOEoIcR1+fdUFkviiOfI
vnSFXdnLIgwnWeYIXY618RaTsGwwqXlNiSen1BfdKe6qjTU8vZIhCKphlRful74a
xzMOCeHFhGY2DQJfjCepkZXS3nM4fuiHtujO+ZQWtGf7FQx4clD0f0WMilM3VGxA
DgwTZOBl9bWzni2yyv6qoi4qhXaPdDqlUuZ1QkWJdPTONHJnEGpVQoq8dZtd3tEd
NCA/SCuj5/GV9rZRs6PJ0yMg1mpyhMAvGWlRamWhkk9kJenXVF4uxZgNCihNdY5E
E8aMnjZR9AWXNjeK9w0FIsdjM2ZbqH8ee8acbiDstBAcA5hFlRjUaewfgX1oSgCm
dMGgolCWJ2gzLGWkCsTwj113G9s2XfldnmLge63onQFLk+a3rtHQm9a2kdAmV1pc
7pVGpWzXpIkVJxi9W9f7ISX6Acw0NK01Iu6y76tUXjdmQdogz277VUWeP4oiHWko
X8ruvvb9EAEtqm8hZ26cjKES683MGWFvRrOdT/73ApA7sssaHJOejVncAjMl7jI/
GkPZ4/2BM75iCv5zF8IqOd5Et1qU+NPcl77gTzp+KcD1MdLw+mE=
=qwCN
-----END PGP SIGNATURE-----


Closed
Ludovic Courtès wrote 8 years ago
(name . Christopher Baines)(address . mail@cbaines.net)(address . 27650@debbugs.gnu.org)
87vambigv1.fsf@gnu.org
Christopher Baines <mail@cbaines.net> skribis:

Toggle quote (22 lines)
> On Fri, 28 Jul 2017 21:36:10 +0200
> ludo@gnu.org (Ludovic Courtès) wrote:
>
>> Christopher Baines <mail@cbaines.net> skribis:
>>
>> > * gnu/services/admin.scm
>> > (<tailon-configuration>, <tailon-configuration-file>): New record
>> > types. (tailon-configuration-files-string,
>> > tailon-shepherd-service): New procedures.
>> > (%tailon-accounts, tailon-service-type: New variables.
>> > * doc/guix.texi (Monitoring Services: Document the Tailon service.
>> > * gnu/local.mk (GNU_SYSTEM_MODULES): Add it.
>> > * gnu/tests/admin.scm: New file.
>>
>> You also need to add gnu/tests/admin.scm to local.mk, but apart from
>> that it looks perfect to me. Thank you!
>
> The latest patch I send should have included updating local.mk, at
> least the quoted changelog claims to change the file. I'll clarify what
> exactly was added, and look to push this, but do let me know if there
> is something that still needs doing.

I guess we’re done now, thanks!

Ludo’.
?
Your comment

This issue is archived.

To comment on this conversation send an email to 27650@debbugs.gnu.org

To respond to this issue using the mumi CLI, first switch to it
mumi current 27650
Then, you may apply the latest patchset in this issue (with sign off)
mumi am -- -s
Or, compose a reply to this issue
mumi compose
Or, send patches to this issue
mumi send-email *.patch
You may also tag this issue. See list of standard tags. For example, to set the confirmed and easy tags
mumi command -t +confirmed -t +easy
Or, remove the moreinfo tag and set the help tag
mumi command -t -moreinfo -t +help