[systemd-devel] socket based activation for Python?

Gustavo Sverzut Barbieri barbieri at profusion.mobi
Sun Nov 7 08:05:20 PST 2010


On Sun, Nov 7, 2010 at 11:19 AM, Felix Schwarz
<felix.schwarz at oss.schwarz.eu> wrote:
> Hi,
>
> I develop Python software and some of this software comes with a Python
> daemon which is started during boot. Í can write a service file easily, just
> starting the daemon as I do now with a traditional init script.
>
> If I understand the concept correctly, my daemon should use socket-based
> activation for the most efficient usage of systemd. However I did not find
> any reference how to do that in Python…
> To me it looks like sd-daemon and friends are only available for
> applications written in C.
>
> - Is that true?
> - Is there any project to provide systemd glue code to Python?

You can do that in Python, basically you need to check some envvars to
get the file descriptor number then use os.fdopen() to use those
integers as python file objects... or use os.write()/os.read() that
maps directly to C calls. I'm pretty sure there are similar things for
sockets/sendmsg/readmsg.

-- 
Gustavo Sverzut Barbieri
http://profusion.mobi embedded systems
--------------------------------------
MSN: barbieri at gmail.com
Skype: gsbarbieri
Mobile: +55 (19) 9225-2202


More information about the systemd-devel mailing list