-
-
Notifications
You must be signed in to change notification settings - Fork 53
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement listening on activation environment changes #388
Conversation
i think the code quality in this is ok now, what's missing from my side is imo:
|
58a939b
to
3bb42c4
Compare
i also added an option to
as a way to wait until either of the given environment variables becomes available (with |
There is another thing I would like to have while at it and that is unsetting of environment vars. As I see it, we don't have to add a protocol message for it; we can repurpose the
to
and add a new command to thoughts? |
This can go in if you need it. I'm sort of questioning whether this is really the best option though - seems like you basically just need a channel to communicate that something has happened (display server has started, or whatever), and dinit (with a little augmentation) just happens to be able to act as that channel. Could triggered services achieve the same thing? I.e. just trigger some service after setting the environment variable (possibly one service per variable, and you also have the option of having a dependent service which then will only start once all variables have been triggered, for example).
This seems perfectly reasonable to me. |
well we're still using triggered services either way (a persistent watcher process, for now implemented via dinit-monitor, will take care of triggering the service - or well, be one of the sources that can trigger it) the thing is stuff like with this we can have dinit automatically react to it and trigger the right triggered service, without having to patch purpose-specific paths into either dbus, or every single desktop session program, so all the "specific" logic is in things that are particular to dinit services, and the only patched thing is dbus, which is patched with generic logic to update dinit when it's itself updated (logic that is already needed to support dbus services that are supervised via dinit; with dbus-broker we will not even be patching anything anymore, because the controller is specific to the service manager) we are pretty much doing the same thing as systemd in this regard, so it plays along with what everybody already does; having to patch things for dinit in different places would be much more of a pain |
I implemented the rest of what I wanted to do. There is now I updated the manpages too, not sure what to do with tests considering this is only protocol and |
Ok, looks fine. For tests you can add something to |
I added a cptest, seems to be fine |
src/dinit-monitor.cc
Outdated
return false; | ||
} | ||
|
||
static size_t read_and_issue(int socknum, cpbuffer_t &rbuffer, size_t dsz, const std::unordered_set<std::string> &varset, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we name this read_vars_and_issue
or something a little more specific? (I would tend to use process_initial_vars
but whatever, just needs to be a bit more descriptive)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
rbuffer.consume(1); | ||
} | ||
|
||
static size_t get_allenv(int socknum, cpbuffer_t &rbuffer) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So this reads and processes the packet header and leaves the body of the reply pending? Could you add a comment explaining that
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, added
Sorry, just a couple more minor nits (comments above). One more thing is that really, dinit-monitor should check for a compatible protocol version before using the |
i fixed the above, and also incremented the protocol ver to allow it to work at all |
Great, thanks |
This implements a protocol that lets a connection to the control socket listen on changes in the global environment issued by
dinitctl setenv
. This opens up a range of possibilities - such as special services that trigger other services when an environment variable appears.It also implements a
dinit-monitor
environment watching mode as a proof of functionality, though likely not acceptable as is (likely at least thestring_view
will need getting rid of?)I intentionally did not implement things like protocol checking and whatnot yet since I want your feedback first.
I should probably also change the protocol a bit - at very least, the envevent should contain information about whether the envvar is newly created or if it overwrites a previous one.
Let me know what you think :)