From mboxrd@z Thu Jan 1 00:00:00 1970 From: Hartmut Goebel Subject: Re: [PATCH] improve nginx-service Date: Fri, 4 Nov 2016 22:28:07 +0100 Message-ID: References: <20161016143347.38d8a6f2@polymos.lepiller.eu> <874m483vap.fsf@gnu.org> <20161020143744.516a1184@polymos.lepiller.eu> <87shrlzd0w.fsf@gnu.org> <20161026214507.45445d14@lepiller.eu> <87y41aklqp.fsf@gnu.org> <20161027195949.354cae8e@lepiller.eu> <87pomhse6w.fsf@gnu.org> <87lgx0txz0.fsf@gnu.org> <87h97n1iu0.fsf@gnu.org> <20161104190129.684844b4@lepiller.eu> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:45611) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1c2m24-0000jn-HL for guix-devel@gnu.org; Fri, 04 Nov 2016 17:28:17 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1c2m21-0008TE-Av for guix-devel@gnu.org; Fri, 04 Nov 2016 17:28:16 -0400 Received: from mail-out.m-online.net ([212.18.0.10]:50191) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1c2m21-0008RK-10 for guix-devel@gnu.org; Fri, 04 Nov 2016 17:28:13 -0400 Received: from frontend01.mail.m-online.net (unknown [192.168.8.182]) by mail-out.m-online.net (Postfix) with ESMTP id 3t9Zgv39tSz3hj0F for ; Fri, 4 Nov 2016 22:28:11 +0100 (CET) Received: from localhost (dynscan1.mnet-online.de [192.168.6.68]) by mail.m-online.net (Postfix) with ESMTP id 3t9Zgv1H0nzwWfh for ; Fri, 4 Nov 2016 22:28:11 +0100 (CET) Received: from mail.mnet-online.de ([192.168.8.182]) by localhost (dynscan1.mail.m-online.net [192.168.6.68]) (amavisd-new, port 10024) with ESMTP id gYd5kKUJcskZ for ; Fri, 4 Nov 2016 22:28:08 +0100 (CET) Received: from hermia.goebel-consult.de (ppp-188-174-155-245.dynamic.mnet-online.de [188.174.155.245]) (using TLSv1 with cipher DHE-RSA-CAMELLIA256-SHA (256/256 bits)) (No client certificate requested) by mail.mnet-online.de (Postfix) with ESMTPS for ; Fri, 4 Nov 2016 22:28:08 +0100 (CET) Received: from thisbe.goebel-consult.de (hermia.goebel-consult.de [192.168.110.7]) by hermia.goebel-consult.de (Postfix) with ESMTP id C8F5760591 for ; Fri, 4 Nov 2016 22:28:07 +0100 (CET) In-Reply-To: <20161104190129.684844b4@lepiller.eu> List-Id: "Development of GNU Guix and the GNU System distribution." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-devel-bounces+gcggd-guix-devel=m.gmane.org@gnu.org Sender: "Guix-devel" To: guix-devel@gnu.org Hi Julien thanks for these patches. I applied them to current master, but I did not work out how to use the new features. I'd appreciate a more complete example. 0001-Make-nginx-service-extensible.patch > +@deffn {Scheme Variable} nginx-service-type +This is the type for the > nginx web server. + +This service can be extended to add more vhosts > than the default one. + +@example +(simple-service 'my-extra-vhost > nginx-service-type + (list (nginx-vhost-configuration (https-port #f) > + (root "/var/www/extra-website")))) I do not understand this. Why would I want to to this? Why not just add the vhost declaration when defining the service in the system declaration? Is this for vhost-types which have preset values for some configuration files? Then a different example might be useful, and/or some more explanation. It's a bit more obvious with patch 3, but even that example is not that obvious to me and could use some more explanation. I've build a simple service like the gtk-doc-vhost in your second example, but it not manage to make it work: First I got "error: no target of type 'nginx'", so I re-added "(nginx-service)" to the system declaration. Then I got gnu/services/web.scm:118:34: In procedure default-nginx-vhost-config:= gnu/services/web.scm:118:34: In procedure struct_vtable: Wrong type argument in position 1 (expecting struct): (nginx-vhost-configuration (root taler-landing-page)) Si I'd really appreciate seeing a more complete example either in the documentation of in gn/systems/examples/ > (system* (string-append #$nginx "/sbin/nginx") - "-c" #$config-file > "-t"))))) + "-c" #$(or config-file + (default-nginx-config > log-directory + run-directory vhosts)) + "-t"))))) Nitpicking: I'd mode the "-t" to the front, since this is the important difference. > (define nginx-shepherd-service (match-lambda - (($ > nginx log-directory run-directory config-file) + > (($ nginx log-directory run-directory vhosts > config-file) (let* ((nginx-binary (file-append nginx "/sbin/nginx")) > (nginx-action (lambda args #~(lambda _ (zero? - (system* > #$nginx-binary "-c" #$config-file #$@args)))))) + (system* > #$nginx-binary "-c" #$(or config-file + (default-nginx-config + > log-directory + run-directory + vhosts))+ #$@args)))))) To avoid duplicate code I suggest moving the "#$(or =E2=80=A6)" part into= a private function - if this is possible. 0003-services-Accept-gexps-as-nginx-configuration-value.patch > +@example +(simple-service 'gtk-doc-vhost nginx-service-type + (list > (nginx-vhost-configuration git am says: trailing whitespace > + " root " #$(nginx-vhost-configuration-root vhost) ";\n" + " index " > #$(config-index-strings (nginx-vhost-configuration-index vhost)) ";\n" > + " server_tokens " #$(if (nginx-vhost-configuration-server-tokens? > vhost) + "on" "off") ";\n" Could you please (maybe in another patch) add a way to include additional config lines? Both for the main server and each vhost.I'm gioing to need this for adding locations, backends and such. -- Regards Hartmut Goebel | Hartmut Goebel | h.goebel@crazy-compilers.com | | www.crazy-compilers.com | compilers which you thought are impossible |