diff mbox

services: nginx: Actually check if configuration is valid.

Message ID 1473386715-10297-1-git-send-email-me@tobias.gr
State New
Headers show

Commit Message

Tobias Geerinckx-Rice Sept. 9, 2016, 2:05 a.m. UTC
* gnu/services/web.scm (nginx-activation): Fix path to nginx binary.
---

Hullo again!

I suspect not many people run nginx (or dovecot, but that's a different
matter) on Guix. The nginx activation script will now correctly print a
non-fatal error if the configuration smells off.

Why I'm mailing: was this intended to be fatal? It's easy to miss now.

Kind regards,

T G-R

 gnu/services/web.scm | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

David Thompson Sept. 9, 2016, 2:09 a.m. UTC | #1
On Thu, Sep 8, 2016 at 10:05 PM, Tobias Geerinckx-Rice <me@tobias.gr> wrote:
> * gnu/services/web.scm (nginx-activation): Fix path to nginx binary.
> ---
>
> Hullo again!
>
> I suspect not many people run nginx (or dovecot, but that's a different
> matter) on Guix. The nginx activation script will now correctly print a
> non-fatal error if the configuration smells off.

Maybe this could be done at build-time instead?  Would be nice to know
that when you boot the system the nginx config will be valid.

- Dave
Tobias Geerinckx-Rice Sept. 9, 2016, 2:21 a.m. UTC | #2
Dave,

On 09/09/16 04:09, Thompson, David wrote:
> Maybe this could be done at build-time instead?

The nginx service points to a stateful configuration file, like
/etc/nginx.conf, that isn't built or handled by Guix.

I'd like that to change, but that will have to wait for now.

> Would be nice to know that when you boot the system the nginx config 
> will be valid.

It's currently printed near the end of ‘guix system reconfigure’, if
that's what you mean.

Kind regards,

T G-R
David Thompson Sept. 9, 2016, 2:29 a.m. UTC | #3
On Thu, Sep 8, 2016 at 10:21 PM, Tobias Geerinckx-Rice <me@tobias.gr> wrote:
> Dave,
>
> On 09/09/16 04:09, Thompson, David wrote:
>> Maybe this could be done at build-time instead?
>
> The nginx service points to a stateful configuration file, like
> /etc/nginx.conf, that isn't built or handled by Guix.

No, it doesn't.  I wrote the nginx service.  The config file used is
part of the g-expression and is absolutely not stateful.

> I'd like that to change, but that will have to wait for now.
>
>> Would be nice to know that when you boot the system the nginx config
>> will be valid.
>
> It's currently printed near the end of ‘guix system reconfigure’, if
> that's what you mean.

I mean that it should throw an error before the system is made active.
The derivation that builds the service file should fail.  Not
suggesting it needs to be done right now, but I think it would be
cool.

- Dave
Tobias Geerinckx-Rice Sept. 9, 2016, 2:36 a.m. UTC | #4
Hi Dave,

On 09/09/16 04:29, Thompson, David wrote:
> No, it doesn't.  I wrote the nginx service.  The config file used is
> part of the g-expression and is absolutely not stateful.

Wait.

nckx@v5 ~$ sudo herd restart nginx
Service nginx has been stopped.
Service nginx has been started.
nckx@v5 ~$ echo syntax error >> ~/nginx/nginx.conf
nckx@v5 ~$ sudo herd restart nginx
Service nginx has been stopped.
Service nginx could not be started.

> I mean that it should throw an error before the system is made active.
> The derivation that builds the service file should fail.

I think that's what I want too :-)

Kind regards,

T G-R
Ludovic Courtès Sept. 9, 2016, 10:41 p.m. UTC | #5
Tobias Geerinckx-Rice <me@tobias.gr> skribis:

> * gnu/services/web.scm (nginx-activation): Fix path to nginx binary.

OK to push!  :-)

Ludo'.
Ludovic Courtès Sept. 9, 2016, 10:42 p.m. UTC | #6
Hello,

"Thompson, David" <dthompson2@worcester.edu> skribis:

> I mean that it should throw an error before the system is made active.
> The derivation that builds the service file should fail.  Not
> suggesting it needs to be done right now, but I think it would be
> cool.

Yup.  Running “nginx -t” would do the trick, right?

Ludo’.
diff mbox

Patch

diff --git a/gnu/services/web.scm b/gnu/services/web.scm
index d86aab5..5b0e816 100644
--- a/gnu/services/web.scm
+++ b/gnu/services/web.scm
@@ -80,7 +80,7 @@ 
          (format #t "creating nginx run directory '~a'~%" #$run-directory)
          (mkdir-p #$run-directory)
          ;; Check configuration file syntax.
-         (system* (string-append #$nginx "/bin/nginx")
+         (system* (string-append #$nginx "/sbin/nginx")
                   "-c" #$config-file "-t")))))
 
 (define nginx-shepherd-service