View previous topic :: View next topic |
Author |
Message |
flexibeast Guru
Joined: 04 Apr 2022 Posts: 465 Location: Naarm/Melbourne, Australia
|
Posted: Mon Nov 11, 2024 2:33 am Post subject: Problem using s6-notifyoncheck in an s6 service |
|
|
[Administrator note: this post was originally in to the topic splitdebug not working due to path issue, but the post author subsequently requested that it be moved to its own thread. -Hu]
GDH-gentoo wrote: | You mean that you ran s6-notifyoncheck from a shell? If yes, that is not going to work, it needs to inherit the writing end of the readiness notification pipe from s6-supervise, and the number read from the notification-fd file has to match its file descriptor. |
Ah, yeah, indeed - thanks!
GDH-gentoo wrote: | Therefore, it only makes sense to call s6-notifyoncheck from the run script in the service directory (or s6-rc longrun definition directory). |
i'm not working with s6-rc at this point; that'll be something i do the next stage.
Fundamentally, here are the things i'm trying to achieve:
* Learn how to set up pure s6 services before moving to learning how to set up s6-rc services. i've read the s6 and s6-rc documentation - not least because i'm the person who's ported the documentation for both to mdoc(7) - but putting the pieces together is another issue. And i want to do this for two reasons:
* i want to write short, focused-on-necessities-only guides to help people understand set up s6 / s6-rc services, using concrete information - i.e. not just "set up some path", but "set up some path, such as /what/ever, which we'll use in subsequent examples". i've not encountered many / any such guides; instead, i feel like the amount of detail typically provided - as well as the use of execline, even though it's not actually obligatory - is overwhelming and obscuring the simplicity of the core, which i feel in turn discourages people from trying to use s6 and s6-rc. Here's what i've got so far, which is just about using s6-supervise. i want to expand that to including setting up a pure s6 service, and then to expand that to include setting up a scandir, and then to include setting up an s6-rc service, and then to setting up s6-rc more generally.
* Ultimately, i want to set up s6-rc user services on my own box.
The problem i'm having with my Emacs service is that i want to indicate readiness once the server is able to accept requests from emacsclient. The way i'm trying to do this is to have ~/s6/emacs/data/check contain:
Code: | #!/bin/dash
exec emacsclient -e '(if server-mode t)' |
which returns 1 until the emacsclient command succeeds, at which point it returns 0.
My ~/s6/emacs/run file contains:
Code: | export DBUS_SESSION_BUS_ADDRESS=$(cat "${XDG_STATE_HOME}/session-bus-address" | tr -d '\n')
s6-notifyoncheck /usr/bin/emacs --fg-daemon 1>>"${HOME}/.logs/emacs.log" 2>&1 |
But testing shows that as far as s6 is concerned, the service is ready almost immediately - when the reality is, with my config, it takes several seconds for the server to get to a state where an emacsclient command succeeds.
i'm almost certain i'm doing something wrong here - or not doing something right - but i can't figure out what, and how to isolate the problem. So, suggestions welcome - although probably in a new discussion thread, i guess.
[Administrator edit: Changed quote blocks from [quote="GDH-gentoo"] to [quote="GDH-gentoo"] to maintain connectivity to the original post, since this post is now in a separate thread. -Hu] _________________ https://wiki.gentoo.org/wiki/User:Flexibeast |
|
Back to top |
|
|
GDH-gentoo Veteran
Joined: 20 Jul 2019 Posts: 1710 Location: South America
|
Posted: Mon Nov 11, 2024 12:49 pm Post subject: Re: Problem using s6-notifyoncheck in an s6 service |
|
|
flexibeast wrote: | ~/s6/emacs/data/check contain:
Code: | #!/bin/dash
exec emacsclient -e '(if server-mode t)' |
which returns 1 until the emacsclient command succeeds, at which point it returns 0.
My ~/s6/emacs/run file contains:
Code: | export DBUS_SESSION_BUS_ADDRESS=$(cat "${XDG_STATE_HOME}/session-bus-address" | tr -d '\n')
s6-notifyoncheck /usr/bin/emacs --fg-daemon 1>>"${HOME}/.logs/emacs.log" 2>&1 |
But testing shows that as far as s6 is concerned, the service is ready almost immediately - when the reality is, with my config, it takes several seconds for the server to get to a state where an emacsclient command succeeds. |
I'm familiar with the s6 ecosystem, but not with Emacs. From the s6 side, the setup looks mostly correct to me, except that the run script should likely end with exec s6-notifyoncheck.
From the Emacs side, I don't know if emacsclient -e '(if server-mode t)' is a good polling mechanism; judging by your description of its exit codes, and assuming that it exits immediately, it appears to be.
So, the problem here is that s6-supervise claims that the service is ready before you believe that it actually is? How do you determine that? The difference between the "up" and "ready" timestamps in the output of s6-svstat is too short? s6-svc -uwU returns too soon? _________________
NeddySeagoon wrote: | I'm not a witch, I'm a retired electronics engineer |
Ionen wrote: | As a packager I just don't want things to get messier with weird build systems and multiple toolchains requirements though |
|
|
Back to top |
|
|
flexibeast Guru
Joined: 04 Apr 2022 Posts: 465 Location: Naarm/Melbourne, Australia
|
Posted: Thu Nov 21, 2024 8:38 am Post subject: |
|
|
Finally coming back to this; sorry for having taken so long to reply!
i prepended exec to the last line of the run file.
My test setup is this:
- i have two terminal windows open. In the first, i type
Code: | $ s6-supervise ~/s6/emacs |
without yet pressing ENTER. In the second, i type
Code: | $ s6-svstat ~/s6/emacs && emacsclient -c |
again without yet pressing ENTER.
i focus the first window, press ENTER, and then immediately switch to the other window and press ENTER.
The result in the second window is:
Code: | $ s6-svstat ~/s6/emacs && emacsclient -c
up (pid 4338 pgid 4338) 0 seconds
emacsclient: can't find socket; have you started the server?
emacsclient: To start the server in Emacs, type "M-x server-start".
emacsclient: No socket or alternate editor. Please use:
--socket-name
--server-file (or environment variable EMACS_SERVER_FILE)
--alternate-editor (or environment variable ALTERNATE_EDITOR) |
So it's saying it's "up" even though the server is still in the process of starting up, which takes several seconds. Once the server is running and actually accepting connections, the output of calling `emacsclient -c` is:
Code: | $ emacsclient -c
Waiting for Emacs... |
_________________ https://wiki.gentoo.org/wiki/User:Flexibeast |
|
Back to top |
|
|
GDH-gentoo Veteran
Joined: 20 Jul 2019 Posts: 1710 Location: South America
|
Posted: Thu Nov 21, 2024 12:41 pm Post subject: |
|
|
flexibeast wrote: | The result in the second window is:
Code: | $ s6-svstat ~/s6/emacs && emacsclient -c
up (pid 4338 pgid 4338) 0 seconds
... |
So it's saying it's "up" even though the server is still in the process of starting up, which takes several seconds. |
That's expected, and correct When s6-svstat says "up", it only means that s6-supervise started the service —that is, executed the run file—. If you enable readiness notification by creating a notification-fd file, the output changes to something like:
Code: | up (pid 4338 pgid 4338) xxx seconds, ready xxx seconds |
when the service is up and ready. Note that your output does not show a "ready" timestamp, so emacs was not ready yet (according to your poller).
Change the command in your second window to:
Code: | $ s6-svwait -U ~/s6/emacs && s6-svstat ~/s6/emacs && emacsclient -c |
_________________
NeddySeagoon wrote: | I'm not a witch, I'm a retired electronics engineer |
Ionen wrote: | As a packager I just don't want things to get messier with weird build systems and multiple toolchains requirements though |
|
|
Back to top |
|
|
flexibeast Guru
Joined: 04 Apr 2022 Posts: 465 Location: Naarm/Melbourne, Australia
|
Posted: Sat Nov 23, 2024 4:26 am Post subject: |
|
|
Changing the command in the second window to the one you specified, i.e.
Code: | $ s6-svwait -U ~/s6/emacs && s6-svstat ~/s6/emacs && emacsclient -c |
results in no output in the terminal, an emacsclient instance never starting, and never getting a prompt back. However, several seconds after running that command line, i can successfully manually start an emacsclient instance by doing so outside of that window (more specifically, via a shell script i run from Wofi), so the server has started successfully. And indeed, running ~/s6/emacs/data/check manually at that point returns 0:
Code: | $ ~/s6/emacs/data/check
t
$ echo $?
0 |
_________________ https://wiki.gentoo.org/wiki/User:Flexibeast |
|
Back to top |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|