Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Problem using s6-notifyoncheck in an s6 service
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Portage & Programming
View previous topic :: View next topic  
Author Message
flexibeast
Guru
Guru


Joined: 04 Apr 2022
Posts: 449
Location: Naarm/Melbourne, Australia

PostPosted: Mon Nov 11, 2024 2:33 am    Post subject: Problem using s6-notifyoncheck in an s6 service Reply with quote

[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
View user's profile Send private message
GDH-gentoo
Veteran
Veteran


Joined: 20 Jul 2019
Posts: 1693
Location: South America

PostPosted: Mon Nov 11, 2024 12:49 pm    Post subject: Re: Problem using s6-notifyoncheck in an s6 service Reply with quote

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
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Portage & Programming All times are GMT
Page 1 of 1

 
Jump to:  
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