unofficial mirror of guix-devel@gnu.org 
 help / color / mirror / code / Atom feed
* need help with debugging gopherd (geomyidae) service
@ 2017-05-10  1:27 ng0
  2017-05-16  7:44 ` Maxim Cournoyer
  0 siblings, 1 reply; 3+ messages in thread
From: ng0 @ 2017-05-10  1:27 UTC (permalink / raw)
  To: guix-devel

[-- Attachment #1: Type: text/plain, Size: 486 bytes --]

When I start this via the arguments I pass (well, any arguments),
without the service it starts and I can access the server.

The service never starts (and due to its simplistic nature, no
"BOOM CRASH THIS IS WHY I REFUSE TO START" is seen.
In this version I added 'networking' to requirements, still no change.

Anyone got an idea what could be missing from making this simple service
functional?

Patches appended.
-- 
https://pragmatique.xyz
PGP: https://people.pragmatique.xyz/ng0/

[-- Attachment #2: 0001-gnu-Add-geomyidae.patch --]
[-- Type: text/plain, Size: 2753 bytes --]

From b63c5ffd8891c706cd674fcc539dc8280d92dbcb Mon Sep 17 00:00:00 2001
From: ng0 <ng0@no-reply.pragmatique.xyz>
Date: Tue, 9 May 2017 18:52:31 +0000
Subject: [PATCH 1/2] gnu: Add geomyidae.

* gnu/packages/web.scm (geomyidae): New variable.
---
 gnu/packages/web.scm | 43 ++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 42 insertions(+), 1 deletion(-)

diff --git a/gnu/packages/web.scm b/gnu/packages/web.scm
index efaa1b574..69529b5c3 100644
--- a/gnu/packages/web.scm
+++ b/gnu/packages/web.scm
@@ -13,7 +13,7 @@
 ;;; Copyright © 2016 Rene Saavedra <rennes@openmailbox.org>
 ;;; Copyright © 2016 Ben Woodcroft <donttrustben@gmail.com>
 ;;; Copyright © 2016 Clément Lassieur <clement@lassieur.org>
-;;; Copyright © 2016, 2017 ng0 <contact.ng0@cryptolab.net>
+;;; Copyright © 2016, 2017 ng0 <ng0@no-reply.pragmatique.xyz>
 ;;; Copyright © 2016, 2017 Arun Isaac <arunisaac@systemreboot.net>
 ;;; Copyright © 2016 Tobias Geerinckx-Rice <me@tobias.gr>
 ;;; Copyright © 2016 Bake Timmons <b3timmons@speedymail.org>
@@ -4552,3 +4552,44 @@ into your tests.  It automatically starts up a HTTP server in a separate thread
 
 (define-public python2-pytest-httpbin
   (package-with-python2 python-pytest-httpbin))
+
+(define-public geomyidae
+  (let* ((commit "9a2203506973a803e74ffa80a27f2bf1919b68cc")
+         (revision "1"))
+    (package
+      (name "geomyidae")
+      (version (string-append "0.26.3" "-" revision
+                              (string-take commit 7)))
+      (source
+       (origin
+         (method git-fetch)
+         (uri (git-reference
+               (url "git://git.r-36.net/geomyidae")
+               (commit commit)))
+         (file-name (string-append name "-" version "-checkout"))
+         (sha256
+          (base32
+           "1h79w5340wnqzwsxdlfcchmxrr953fwhbgss4mhjg62x7pdkkvab"))))
+      (build-system gnu-build-system)
+      (arguments
+       `(#:make-flags (list "CC=gcc"
+                            (string-append "PREFIX="
+                                           (assoc-ref %outputs "out")))
+         #:tests? #f ;No tests
+         #:phases
+         (modify-phases %standard-phases
+           (delete 'configure))))
+      (home-page "http://git.r-36.net/geomyidae")
+      (synopsis "gopherd server")
+      (description
+       "Geomyidae is a gopherd for GNU/Linux and BSD.
+Its features include:
+
+@enumerate
+@item gopher menus (see index.gph for an example)
+@item dir listings (if no index.gph was found)
+@item cgi support (.cgi files are executed)
+@item search support in CGI files
+@item logging (-l option) and loglevels (-v option)
+@end enumerate\n")
+      (license l:x11))))
-- 
2.12.2


[-- Attachment #3: 0002-services-Add-geomyidae-service.patch --]
[-- Type: text/plain, Size: 8633 bytes --]

From 9d4b74f028575c9acc1ffa486be2a31b5e5e0ae5 Mon Sep 17 00:00:00 2001
From: ng0 <ng0@no-reply.pragmatique.xyz>
Date: Tue, 9 May 2017 18:52:32 +0000
Subject: [PATCH 2/2] services: Add geomyidae-service.

* gnu/services/web.scm (<geomyidae-configuration>): New record type.
(geomyidae-shepherd-service, geomyidae-activation): New procedures.
(geomyidae-service-type, geomyidae-service, %geomyidae-accounts): New variables.
* doc/guix.texi (Web Services): Document it.
---
 doc/guix.texi        |  60 +++++++++++++++++++++++++-
 gnu/services/web.scm | 117 ++++++++++++++++++++++++++++++++++++++++++++++++++-
 2 files changed, 174 insertions(+), 3 deletions(-)

diff --git a/doc/guix.texi b/doc/guix.texi
index 22dc8b3f9..03e66d395 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -26,7 +26,7 @@ Copyright @copyright{} 2016 Ben Woodcroft@*
 Copyright @copyright{} 2016 Chris Marusich@*
 Copyright @copyright{} 2016, 2017 Efraim Flashner@*
 Copyright @copyright{} 2016 John Darrington@*
-Copyright @copyright{} 2016 ng0@*
+Copyright @copyright{} 2016, 2017 ng0@*
 Copyright @copyright{} 2016 Jan Nieuwenhuizen@*
 Copyright @copyright{} 2016 Julien Lepiller@*
 Copyright @copyright{} 2016 Alex ter Weele@*
@@ -13485,6 +13485,64 @@ Whether the server should add its configuration to response.
 @end table
 @end deftp
 
+@cindex gopherd
+@deffn {Scheme Procedure} geomyidae-service- [#:config (geomyidae-configuration)]
+
+Return a service that runs @command{geomyidae}, a simple gopherd server.
+
+The @var{config} argument should be a @code{<geomyidae-configuration>} object,
+by default its root directory is at @file{/srv/gopher} and it listens on the
+default port for gopher, which is @var{70}.
+
+@end deffn
+
+@deftp {Data Type} geomyidae-configuration
+Data type representing the configuration for @code{geomyidae-service}.
+
+@table @asis
+
+@item @code{package} (default: @var{geomyidae})
+Package object of the geomyidae gopherd.
+
+@item @code{logfile} (default: @var{#f})
+Logfile to use, the default is to use no logfile.
+
+@item @code{loglevel} (default: @var{#f})
+If a logfile is used, this sets the loglevel to be used:
+
+0 - no logging
+1 - served plain files
+2 - dir listings
+4 - HTTP redirects
+8 - not found queries
+1 + 2 + 4 = 7 (files + dir listings + HTTP)
+
+Geomyidae defaults to '7' if this is used.
+
+@item @code{htdoc} (default: @var{"/srv/gopher"})
+Rootdirectory to serve from.
+
+@item @code{port} (default: @var{70})
+Port to use, the default gopher port is 70.
+
+@item @code{sport} (default: @var{#f})
+Set the port that should be shown in the gopher dir listings.
+
+@item @code{user} (default: @var{geomyidae})
+User to run the service as.
+
+@item @code{group} (default: @var{geomyidae})
+Group to run the service as.
+
+@item @code{host} (default: @var{localhost})
+Host that should be used in the gopher dir listings.
+
+@item @code{ip} (default: @var{#f})
+IP which geomyidae should bind to.
+
+@end table
+@end deftp
+
 @node VPN Services
 @subsubsection VPN Services
 @cindex VPN (virtual private network)
diff --git a/gnu/services/web.scm b/gnu/services/web.scm
index f85b41215..2cfa835a7 100644
--- a/gnu/services/web.scm
+++ b/gnu/services/web.scm
@@ -1,7 +1,7 @@
 ;;; GNU Guix --- Functional package management for GNU
 ;;; Copyright © 2015 David Thompson <davet@gnu.org>
 ;;; Copyright © 2015, 2016, 2017 Ludovic Courtès <ludo@gnu.org>
-;;; Copyright © 2016 ng0 <ng0@we.make.ritual.n0.is>
+;;; Copyright © 2016, 2017 ng0 <ng0@no-reply.pragmatique.xyz>
 ;;; Copyright © 2016, 2017 Julien Lepiller <julien@lepiller.eu>
 ;;; Copyright © 2017 Christopher Baines <mail@cbaines.net>
 ;;;
@@ -41,7 +41,12 @@
             nginx-named-location-configuration
             nginx-named-location-configuration?
             nginx-service
-            nginx-service-type))
+            nginx-service-type
+
+            geomyidae-service
+            geomyidae-service-type
+            geomyidae-configuration
+            geomyidae-configuration?))
 
 ;;; Commentary:
 ;;;
@@ -305,3 +310,111 @@ files in LOG-DIRECTORY, and stores temporary runtime files in RUN-DIRECTORY."
             (server-blocks server-list)
             (upstream-blocks upstream-list)
             (file config-file))))
+
+;;;
+;;; geomyidae
+;;;
+
+(define-record-type* <geomyidae-configuration>
+  geomyidae-configuration make-geomyidae-configuration
+  geomyidae-configuration?
+  (package  geomyidae-configuration-package ;package
+            (default geomyidae))
+  (logfile  geomyidae-configuration-logfile ;string
+            (default "/var/log/geomyidae.log"))
+  (loglevel geomyidae-configuration-loglevel ;number
+            (default 7))
+  (htdocs   geomyidae-configuration-htdocs ;string
+            (default "/srv/gopher"))
+  (port     geomyidae-configuration-port ;number
+            (default 70))
+  (sport    geomyidae-configuration-sport ;number
+            (default 70))
+  (host     geomyidae-configuration-host ;string
+            (default "localhost"))
+  (ip       geomyidae-configuration-ip ;string
+            (default #f)))
+
+(define geomyidae-shepherd-service
+  (match-lambda
+    (($ <geomyidae-configuration>
+        package logfile loglevel htdocs port
+        sport host ip);;user group
+     (let* ((geomyidae (file-append package "/bin/geomyidae"))
+            (cmd `(,geomyidae
+                   "-d"
+                   ,@(if logfile
+                         `(,(string-append "-l " logfile))
+                         '())
+                   ,@(if loglevel
+                         `(,(string-append
+                             "-v " (number->string loglevel)))
+                         '())
+                   ,@(if htdocs
+                         `(,(string-append "-b " htdocs))
+                         '())
+                   ,@(if port
+                         `(,(string-append
+                             "-p " (number->string port)))
+                         '())
+                   ,@(if sport
+                         `(,(string-append
+                             "-o " (number->string sport)))
+                         '())
+                   ,@(if host
+                         `(,(string-append "-h " host))
+                         '())
+                   ,@(if ip
+                         `(,(string-append "-i " ip))
+                         '()))))
+       (list (shepherd-service
+              (documentation "Run the gopherd geomyidae")
+              (provision '(geomyidae))
+              (requirement '(user-processes loopback networking))
+              (start #~(make-forkexec-constructor
+                        '#$cmd
+                        #:user "geomyidae"
+                        #:group "geomyidae"
+                        #:pid-file "/var/run/geomyidae.pid"))
+              (stop #~(make-kill-destructor))))))))
+
+(define %geomyidae-accounts
+  ;; User account and group for the geomyidae gopherd.
+  (list (user-group
+         (name "geomyidae")
+         (system? #t))
+        (user-account
+         (name "geomyidae")
+         (system? #t)
+         (group "geomyidae")
+         (comment "geomyidae user")
+         (home-directory "/var/empty")
+         (shell (file-append shadow "/sbin/nologin")))))
+
+(define (geomyidae-activation config)
+  "Return the activation gexp for geomyidae using CONFIG."
+  (let ((htdocs (geomyidae-configuration-htdocs config)))
+    #~(begin
+        (use-modules (guix build utils))
+        ;; Create the 'htdocs' directory when it's not '#f'.
+        (and=> #$htdocs mkdir-p))))
+
+(define geomyidae-service-type
+  (service-type
+   (name 'geomyidae)
+   (extensions
+    (list (service-extension shepherd-root-service-type
+                             geomyidae-shepherd-service)
+          (service-extension account-service-type
+                             (const %geomyidae-accounts))
+          (service-extension activation-service-type
+                             geomyidae-activation)))))
+
+(define* (geomyidae-service #:key (config (geomyidae-configuration)))
+  "Return a service that runs @command{geomyidae}, a simple gopherd server.
+
+The @var{config} argument should be a
+@code{<geomyidae-configuration> oject, by default its root directory is
+at @file{/srv/gopher} and it listens on the default port for gopher, which
+is @var{70}."
+  (service geomyidae-service-type config))
-- 
2.12.2


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: need help with debugging gopherd (geomyidae) service
  2017-05-10  1:27 need help with debugging gopherd (geomyidae) service ng0
@ 2017-05-16  7:44 ` Maxim Cournoyer
  2017-05-17 12:58   ` Ludovic Courtès
  0 siblings, 1 reply; 3+ messages in thread
From: Maxim Cournoyer @ 2017-05-16  7:44 UTC (permalink / raw)
  To: guix-devel

[-- Attachment #1: Type: text/plain, Size: 4637 bytes --]

ng0 <ng0@pragmatique.xyz> writes:

> When I start this via the arguments I pass (well, any arguments),
> without the service it starts and I can access the server.
>
> The service never starts (and due to its simplistic nature, no
> "BOOM CRASH THIS IS WHY I REFUSE TO START" is seen.
> In this version I added 'networking' to requirements, still no change.
>
> Anyone got an idea what could be missing from making this simple service
> functional?
>

[...]
> diff --git a/gnu/services/web.scm b/gnu/services/web.scm
> index f85b41215..2cfa835a7 100644
> --- a/gnu/services/web.scm
> +++ b/gnu/services/web.scm
> @@ -1,7 +1,7 @@
>  ;;; GNU Guix --- Functional package management for GNU
>  ;;; Copyright © 2015 David Thompson <davet@gnu.org>
>  ;;; Copyright © 2015, 2016, 2017 Ludovic Courtès <ludo@gnu.org>
> -;;; Copyright © 2016 ng0 <ng0@we.make.ritual.n0.is>
> +;;; Copyright © 2016, 2017 ng0 <ng0@no-reply.pragmatique.xyz>
>  ;;; Copyright © 2016, 2017 Julien Lepiller <julien@lepiller.eu>
>  ;;; Copyright © 2017 Christopher Baines <mail@cbaines.net>
>  ;;;
> @@ -41,7 +41,12 @@
>              nginx-named-location-configuration
>              nginx-named-location-configuration?
>              nginx-service
> -            nginx-service-type))
> +            nginx-service-type
> +
> +            geomyidae-service
> +            geomyidae-service-type
> +            geomyidae-configuration
> +            geomyidae-configuration?))
>  
>  ;;; Commentary:
>  ;;;
> @@ -305,3 +310,111 @@ files in LOG-DIRECTORY, and stores temporary runtime files in RUN-DIRECTORY."
>              (server-blocks server-list)
>              (upstream-blocks upstream-list)
>              (file config-file))))
> +
> +;;;
> +;;; geomyidae
> +;;;
> +
> +(define-record-type* <geomyidae-configuration>
> +  geomyidae-configuration make-geomyidae-configuration
> +  geomyidae-configuration?
> +  (package  geomyidae-configuration-package ;package
> +            (default geomyidae))
> +  (logfile  geomyidae-configuration-logfile ;string
> +            (default "/var/log/geomyidae.log"))
> +  (loglevel geomyidae-configuration-loglevel ;number
> +            (default 7))
> +  (htdocs   geomyidae-configuration-htdocs ;string
> +            (default "/srv/gopher"))
> +  (port     geomyidae-configuration-port ;number
> +            (default 70))
> +  (sport    geomyidae-configuration-sport ;number
> +            (default 70))
> +  (host     geomyidae-configuration-host ;string
> +            (default "localhost"))
> +  (ip       geomyidae-configuration-ip ;string
> +            (default #f)))
> +
> +(define geomyidae-shepherd-service
> +  (match-lambda
> +    (($ <geomyidae-configuration>
> +        package logfile loglevel htdocs port
> +        sport host ip);;user group
> +     (let* ((geomyidae (file-append package "/bin/geomyidae"))
> +            (cmd `(,geomyidae
> +                   "-d"
> +                   ,@(if logfile
> +                         `(,(string-append "-l " logfile))
> +                         '())
> +                   ,@(if loglevel
> +                         `(,(string-append
> +                             "-v " (number->string loglevel)))
> +                         '())
> +                   ,@(if htdocs
> +                         `(,(string-append "-b " htdocs))
> +                         '())
> +                   ,@(if port
> +                         `(,(string-append
> +                             "-p " (number->string port)))
> +                         '())
> +                   ,@(if sport
> +                         `(,(string-append
> +                             "-o " (number->string sport)))
> +                         '())
> +                   ,@(if host
> +                         `(,(string-append "-h " host))
> +                         '())
> +                   ,@(if ip
> +                         `(,(string-append "-i " ip))
> +                         '()))))
> +       (list (shepherd-service
> +              (documentation "Run the gopherd geomyidae")
> +              (provision '(geomyidae))
> +              (requirement '(user-processes loopback networking))
> +              (start #~(make-forkexec-constructor
> +                        '#$cmd

Why is there a single quote in front of #$cmd ?

I think Ludo once explained how to manually exercise the service script;
I'm not sure, but maybe you could gather more clues as to what might be
failing from there if you could manage to run the service manually at
the REPL.

Maxim

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 832 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: need help with debugging gopherd (geomyidae) service
  2017-05-16  7:44 ` Maxim Cournoyer
@ 2017-05-17 12:58   ` Ludovic Courtès
  0 siblings, 0 replies; 3+ messages in thread
From: Ludovic Courtès @ 2017-05-17 12:58 UTC (permalink / raw)
  To: Maxim Cournoyer; +Cc: guix-devel

Maxim Cournoyer <maxim.cournoyer@gmail.com> skribis:

> ng0 <ng0@pragmatique.xyz> writes:

[...]

>> +       (list (shepherd-service
>> +              (documentation "Run the gopherd geomyidae")
>> +              (provision '(geomyidae))
>> +              (requirement '(user-processes loopback networking))
>> +              (start #~(make-forkexec-constructor
>> +                        '#$cmd
>
> Why is there a single quote in front of #$cmd ?
>
> I think Ludo once explained how to manually exercise the service script;
> I'm not sure, but maybe you could gather more clues as to what might be
> failing from there if you could manage to run the service manually at
> the REPL.

If you test this in a VM, error messages will go to /dev/console, so you
should be able to get hints.

HTH,
Ludo’.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2017-05-17 12:58 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-05-10  1:27 need help with debugging gopherd (geomyidae) service ng0
2017-05-16  7:44 ` Maxim Cournoyer
2017-05-17 12:58   ` Ludovic Courtès

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).