Closed henne90gen closed 4 years ago
hi @henne90gen ,
you can create transient units with pystemd... for services, using pystemd.run
is the best way, and i plan to extend pystemd.run to support .path
.socket
and .timer
also...
with that said, right now, its not the easiest thing to do, but you can create timers and other units you just use StartTransientUnit from pystemd.systemd1.Manager object... an example is here
https://github.com/facebookincubator/pystemd/blob/master/examples/start_multiple_transient_unit.py
it does require you to know a little bit about what you are doing, but hey! you can always come here and ask.
will update here if/when pystemd.run
support timers path and other stuff.
note: keep in mind that i'm talking about transient units, for non transient units, you probably should let your configuration management to deal with those.
Hope this helps!!
So it is not planned to add support for non transient units to pystemd? I would love to be able to define a service in my python code and have it installed as a permanent systemd service.
i agree it would be cool to do that... :D , and maybe some day we will do it, but as of now, we dont want to do it... you see, pystemd is just a python interface to systemd... we dont do anything systemd (and more specifically libsystemd) dont already do. And systemd does not provide a public interface for creating non-transient units.
with that said, i dont think it would be hard to implement yourself... maybe some interface between yaml/multidict and then a rendered to convert to the .ini-ish
file...
anyway will comment back once timers and path are part of pystemd.run
I would love to contribute to pystemd and create an API like pystemd.create
, which would create a non-transient unit.
Is that something that could get merged into the project or are you not interested in that?
thanks for the offering, but we dont think this is something that should be part of pystemd.
But if you do it a separate project, i would be more than happy to contribute to that!, i do think its a cool idea, just dont think it belong in pystemd.
with that said, i dont think it would be hard to implement yourself... maybe some interface between yaml/multidict and then a rendered to convert to the .ini-ish file...
python has support for parsing and generating ini files via the configparser
module. It would be pretty easy to use this to generate systemd units and drop them in the appropriate path.
Is it possible to create services or timers with pystemd? It would be awesome to be able to create these without having to copy files, but instead setting them up in python code.