unofficial mirror of bug-guix@gnu.org 
 help / color / mirror / code / Atom feed
* bug#59515: nginx: Fails to start on boot while upstream service is not yet running
@ 2022-11-23 15:34 Jonathan Brielmaier
  2022-11-23 17:35 ` mirai
  2022-11-25  8:56 ` Jonathan Brielmaier
  0 siblings, 2 replies; 4+ messages in thread
From: Jonathan Brielmaier @ 2022-11-23 15:34 UTC (permalink / raw)
  To: 59515

When I start my personal server with a radicale service behind a nginx
reverse proxy, nginx fails to start.

The relevant part in the log:
Nov 23 16:02:56 localhost shepherd[1]: Service networking has been started.
Nov 23 16:02:56 localhost shepherd[1]: Service radicale has been started.
Nov 23 16:02:56 localhost shepherd[1]: Service ssh-daemon has been started.
Nov 23 16:02:56 localhost shepherd[1]: [nginx] nginx: [emerg] host not
found in upstream "localhost:5232" in
/gnu/store/y29zl57pprwxbcxfx593s16456kxk99y-nginx.conf:15
Nov 23 16:02:56 localhost shepherd[1]: Failed to start nginx in the
background.

The config can be found here:
https://gitlab.com/jonsger/jonsger-guix/-/blob/master/config/baebia.scm#L116
```
(upstream-blocks (list
   (nginx-upstream-configuration
     (name "radicale")
     (servers (list "localhost:5232")))))
```

I wonder whats going wrong here. Is there a way to define that nginx
service should wait until radicale service is started?

~Jonathan




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

* bug#59515: nginx: Fails to start on boot while upstream service is not yet running
  2022-11-23 15:34 bug#59515: nginx: Fails to start on boot while upstream service is not yet running Jonathan Brielmaier
@ 2022-11-23 17:35 ` mirai
  2022-11-25  8:56 ` Jonathan Brielmaier
  1 sibling, 0 replies; 4+ messages in thread
From: mirai @ 2022-11-23 17:35 UTC (permalink / raw)
  To: 59515

nginx-configuration has a 'shepherd-requirement' parameter that can be used here




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

* bug#59515: nginx: Fails to start on boot while upstream service is not yet running
  2022-11-23 15:34 bug#59515: nginx: Fails to start on boot while upstream service is not yet running Jonathan Brielmaier
  2022-11-23 17:35 ` mirai
@ 2022-11-25  8:56 ` Jonathan Brielmaier
  2022-11-27 21:14   ` Ludovic Courtès
  1 sibling, 1 reply; 4+ messages in thread
From: Jonathan Brielmaier @ 2022-11-25  8:56 UTC (permalink / raw)
  To: 59515

Ah thanks.

I added `(shepherd-requirement '(radicale))` to my nginx-configuration.
Sadly the issue is not fixed, the situation is the same as before.

I assume that radicale takes a fracture of a second to start. And nginx
starts faster up. See this small experiment:

$ sudo herd stop radicale
$ sudo herd start radicale; curl localhost:5232
Service radicale has been started.
curl: (7) Failed to connect to localhost port 5232 after 0 ms:
Verbindungsaufbau abgelehnt

$ sudo herd stop radicale
$ sudo herd start radicale; sleep 0.2; curl localhost:5232
Service radicale has been started.
Redirected to /.web




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

* bug#59515: nginx: Fails to start on boot while upstream service is not yet running
  2022-11-25  8:56 ` Jonathan Brielmaier
@ 2022-11-27 21:14   ` Ludovic Courtès
  0 siblings, 0 replies; 4+ messages in thread
From: Ludovic Courtès @ 2022-11-27 21:14 UTC (permalink / raw)
  To: Jonathan Brielmaier; +Cc: 59515

Jonathan Brielmaier <jonathan.brielmaier@web.de> skribis:

> I added `(shepherd-requirement '(radicale))` to my nginx-configuration.
> Sadly the issue is not fixed, the situation is the same as before.
>
> I assume that radicale takes a fracture of a second to start. And nginx
> starts faster up. See this small experiment:

That looks like a bug in the radicale service: there’s no
synchronization upon startup:

--8<---------------cut here---------------start------------->8---
     (list (shepherd-service
            (provision '(radicale))
            (documentation "Run the radicale daemon.")
            (requirement '(networking))
            (start #~(make-forkexec-constructor
                      (list #$(file-append package "/bin/radicale")
                        "-C" #$config-file)
                      #:user "radicale"
                      #:group "radicale"))
            (stop #~(make-kill-destructor))))
--8<---------------cut here---------------end--------------->8---

It should wait for a PID file or be started as a systemd or inetd
service.  That way, we’d be sure that shepherd considers it started once
it’s really listening for input.  A quick grep in the source suggests it
creates a PID file somewhere.

HTH!

Ludo’.




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

end of thread, other threads:[~2022-11-27 21:15 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-23 15:34 bug#59515: nginx: Fails to start on boot while upstream service is not yet running Jonathan Brielmaier
2022-11-23 17:35 ` mirai
2022-11-25  8:56 ` Jonathan Brielmaier
2022-11-27 21:14   ` 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).