emacs-bug-tracker
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[debbugs-tracker] bug#27650: closed ([PATCH] gnu: services: admin: Add t


From: GNU bug Tracking System
Subject: [debbugs-tracker] bug#27650: closed ([PATCH] gnu: services: admin: Add tailon.)
Date: Sat, 29 Jul 2017 12:01:02 +0000

Your message dated Sat, 29 Jul 2017 13:00:53 +0100
with message-id <address@hidden>
and subject line Re: [bug#27650] [PATCH] gnu: services: admin: Add tailon.
has caused the debbugs.gnu.org bug report #27650,
regarding [PATCH] gnu: services: admin: Add tailon.
to be marked as done.

(If you believe you have received this mail in error, please contact
address@hidden)


-- 
27650: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=27650
GNU Bug Tracking System
Contact address@hidden with problems
--- Begin Message --- Subject: [PATCH] gnu: services: admin: Add tailon. Date: Tue, 11 Jul 2017 07:56:34 +0100
* 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(-)

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
 
address@hidden Monitoring Services
address@hidden Monitoring Services
+
address@hidden 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).
+
address@hidden
+(service tailon-service-type)
address@hidden example
+
+The following example customises more of the Tailon configuration,
+adding ``sed'' to the list of allowed commands.
+
address@hidden
+(service tailon-service-type
+         (tailon-configuration
+           (config-file
+             (tailon-configuration-file
+               (allowed-commands '("tail" "grep" "awk" "sed"))))))
address@hidden example
+
+
address@hidden {Data Type} tailon-configuration
+Data type representing the configuration of tailon.
+This type has the following parameters:
+
address@hidden @asis
address@hidden @code{config-file} (default: @code{(tailon-configuration-file)})
+The configuration file to use for Tailon. This can be set to a
address@hidden record value, or any gexp
+(@pxref{G-Expressions}).
+
+For example, to instead use a local file, the @code{local-file} function
+can be used:
+
address@hidden
+(service tailon-service-type
+         (tailon-configuration
+           (config-file (local-file "./my-tailon.conf"))))
address@hidden example
+
address@hidden @code{package} (default: @code{tailon})
+The tailon package to use.
+
address@hidden table
address@hidden deftp
+
address@hidden {Data Type} tailon-configuration-file
+Data type representing the configuration options for Tailon.
+This type has the following parameters:
+
address@hidden @asis
address@hidden @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.
+
address@hidden @code{bind} (default: @code{"localhost:8080"})
+Address and port to which Tailon should bind on.
+
address@hidden @code{relative-root-path} (default: @code{#f})
+Prefix to use for all paths, set to @code{#f} to disable using a prefix.
+
address@hidden @code{allow-transfers?} (default: @code{#t})
+Allow downloading the log files in the web interface.
+
address@hidden @code{follow-names?} (default: @code{#t})
+Allow tailing of not-yet existent files.
+
address@hidden @code{tail-lines} (default: @code{200})
+Number of lines to read initially from each file.
+
address@hidden @code{allowed-commands} (default: @code{(list "tail" "grep" 
"awk")})
+Commands to allow running. By default, @code{sed} is disabled.
+
address@hidden @code{debug?} (default: @code{#f})
+Set @code{debug?} to @code{#t} to show debug messages.
+
address@hidden table
address@hidden 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




--- End Message ---
--- Begin Message --- Subject: Re: [bug#27650] [PATCH] gnu: services: admin: Add tailon. Date: Sat, 29 Jul 2017 13:00:53 +0100
On Fri, 28 Jul 2017 22:00:22 +0100
Christopher Baines <address@hidden> wrote:

> On Fri, 28 Jul 2017 21:36:10 +0200
> address@hidden (Ludovic Courtès) wrote:
> 
> > Christopher Baines <address@hidden> 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!

Attachment: pgpNC_v_HKhc9.pgp
Description: OpenPGP digital signature


--- End Message ---

reply via email to

[Prev in Thread] Current Thread [Next in Thread]