On Thu, Jun 05, 2014 at 05:34:01PM -0400, Paul Alfille wrote: > Tomasz, > > I'm having trouble visualizing how the systemd triggering works. When a > program like owread tries to contact owserver, is owserver started? Is this > done by monitoring the typical owserver port (4304)? How about other > owserver friends?
Hi Paul, Socket activation works is basically an inetd-like functionality. Systemd binds to 4304 port and listens. When owread (or anything else) tries to connect to 4304, owserver is started (by systemd) and connection is handled to owserver. (in addition to TCP/UDP ports, systemd can also listen on UNIX sockets, FIFOs, netlink messages and few more sources; but it is not relevant to owfs). In Fedora, I treat owserver as a central multiplexer. Other utilities (owhttpd, owftpd, fuse etc.) do not control 1-wire bus directly, but connect to owserver. It's been working fine for few months (I did not receive any bugreports). For the reference, here are *.service definition that I use: http://pkgs.fedoraproject.org/cgit/owfs.git/tree/ With one central multiplexer, admin has only to customize owserver.service file and put his adapter settings there. Socket activation would let me simplify the dependencies encoded in *.service files - I would be able to drop Requires=/After=owserver.service lines. It would also make possible to restart owserver without dropping connections from owhttpd/owftpd/fuse etc. > If you don't mind describing the process more, or giving pointers to > documentation, perhaps we can assist in the implementation. > > I looked at the code you referenced (iodine), but it doesn't have any > explanations. Is iodine an example client or the controlling code? Controlling code lies in systemd. iodine is a "client". Traditionally, in order to accept network connections, you have to: - bind() socket - listen() on it - accept() incoming connections Those 3 steps are delegated to systemd. When owserver is started by socket activation, it receives already connected file handles to sockets. The code in iodine represents how autodetection works: if there are LISTEN_PID and LISTEN_FDS variables in environment, that means we are started under systemd socket-activation. If the are no LISTEN_* vars, code fallbacks to manually establishing sockets. Longer writeups are available: http://0pointer.de/blog/projects/socket-activation.html http://0pointer.de/blog/projects/socket-activation2.html I've personally used iodine patch as an example when implementing socket activation in some small utilities. Socket activation is inspired by Darwin's launchd feature. That's why I've asked about launchd in context of Mac porting. I don't know launchd, but maybe some code can be shared? -- Tomasz Torcz 72->| 80->| xmpp: zdzich...@chrome.pl 72->| 80->| ------------------------------------------------------------------------------ HPCC Systems Open Source Big Data Platform from LexisNexis Risk Solutions Find What Matters Most in Your Big Data with HPCC Systems Open Source. Fast. Scalable. Simple. Ideal for Dirty Data. Leverages Graph Analysis for Fast Processing & Easy Data Exploration http://www.hpccsystems.com _______________________________________________ Owfs-developers mailing list Owfs-developers@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/owfs-developers