-
Notifications
You must be signed in to change notification settings - Fork 6
Creation of units and services? #6
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
Comments
Hi, well, to answer most of your questions, see below a screenshot from some Trello board, where I gathered all ideas and roadmap items for this project so far: That shown, I regret there isn't any support for unit creation/modification, out of the code. Also, I didn't have the time to think about concepts yet, i.e. how to integrate it into the API (until today). Most probably I'd go for introducing some new builder-like set of classes and/or loader code for templates, like you describe here. Then, putting code in place to write files to the known locations (https://www.freedesktop.org/software/systemd/man/systemd.unit.html), by making use of already defined constants (like
Nearly all of the code (interfaces etc.) is used to make method/property/signal interaction via D-Bus work (and to simplify access to all the stuff that systemd provides on units). I don't think there is a particular class/interface, that is worth to derive from, in order to make this new feature more compliant to the existing code. |
- Specifically service units for now. - Using my own version number - Using lombok to reduce builder code. thjomnx#6 (comment)
- Introduced a Struct and Pair class as needed by dbus-java - Updated various versions I am labeling this version as 2.2.0-eks so if this commit is accepted, be sure to remove -eks. --- In a working state. Needed to also use a special struct class for the disableUnitFiles call (+3 squashed commit) Squashed commit: [9dde539] Found that `enableUnitFiles` may perform what I need to get units started. The `List<UnitFileChange>` is not the proper return type. Some research lead me to AgNO3 project that uses a Tuple type of structure to hold the return type: https://github.com/AgNO3/code/blob/main/orchestrator/agent/system/eu.agno3.orchestrator.system.init.systemd/src/main/java/org/freedesktop/systemd1/Manager.java Still experimenting... [7197b50] WIP: TDD and fleshing out unit creation with dbus [fb4e92d] Starting work towards creating/update/delete units - Specifically service units for now. - Using my own version number - Using lombok to reduce builder code. thjomnx#6 (comment)
- Introduced a Struct and Pair class as needed by dbus-java - Updated various versions I am labeling this version as 2.2.0-eks so if this commit is accepted, be sure to remove -eks. --- In a working state. Needed to also use a special struct class for the disableUnitFiles call (+3 squashed commit) Squashed commit: [9dde539] Found that `enableUnitFiles` may perform what I need to get units started. The `List<UnitFileChange>` is not the proper return type. Some research lead me to AgNO3 project that uses a Tuple type of structure to hold the return type: https://github.com/AgNO3/code/blob/main/orchestrator/agent/system/eu.agno3.orchestrator.system.init.systemd/src/main/java/org/freedesktop/systemd1/Manager.java Still experimenting... [7197b50] WIP: TDD and fleshing out unit creation with dbus [fb4e92d] Starting work towards creating/update/delete units - Specifically service units for now. - Using my own version number - Using lombok to reduce builder code. thjomnx#6 (comment)
- Introduced a Struct and Pair class as needed by dbus-java - Updated various versions I am labeling this version as 2.2.0-eks so if this commit is accepted, be sure to remove -eks. --- In a working state. Needed to also use a special struct class for the disableUnitFiles call (+3 squashed commit) Squashed commit: [9dde539] Found that `enableUnitFiles` may perform what I need to get units started. The `List<UnitFileChange>` is not the proper return type. Some research lead me to AgNO3 project that uses a Tuple type of structure to hold the return type: https://github.com/AgNO3/code/blob/main/orchestrator/agent/system/eu.agno3.orchestrator.system.init.systemd/src/main/java/org/freedesktop/systemd1/Manager.java Still experimenting... [7197b50] WIP: TDD and fleshing out unit creation with dbus [fb4e92d] Starting work towards creating/update/delete units - Specifically service units for now. - Using my own version number - Using lombok to reduce builder code. thjomnx#6 (comment)
- Introduced a Struct and Pair class as needed by dbus-java - Updated various versions I am labeling this version as 2.2.0-eks so if this commit is accepted, be sure to remove -eks. --- In a working state. Needed to also use a special struct class for the disableUnitFiles call (+3 squashed commit) Squashed commit: [9dde539] Found that `enableUnitFiles` may perform what I need to get units started. The `List<UnitFileChange>` is not the proper return type. Some research lead me to AgNO3 project that uses a Tuple type of structure to hold the return type: https://github.com/AgNO3/code/blob/main/orchestrator/agent/system/eu.agno3.orchestrator.system.init.systemd/src/main/java/org/freedesktop/systemd1/Manager.java Still experimenting... [7197b50] WIP: TDD and fleshing out unit creation with dbus [fb4e92d] Starting work towards creating/update/delete units - Specifically service units for now. - Using my own version number - Using lombok to reduce builder code. thjomnx#6 (comment)
- Introduced a Struct and Pair class as needed by dbus-java - Updated various versions I am labeling this version as 2.2.0-eks so if this commit is accepted, be sure to remove -eks. --- In a working state. Needed to also use a special struct class for the disableUnitFiles call (+3 squashed commit) Squashed commit: [9dde539] Found that `enableUnitFiles` may perform what I need to get units started. The `List<UnitFileChange>` is not the proper return type. Some research lead me to AgNO3 project that uses a Tuple type of structure to hold the return type: https://github.com/AgNO3/code/blob/main/orchestrator/agent/system/eu.agno3.orchestrator.system.init.systemd/src/main/java/org/freedesktop/systemd1/Manager.java Still experimenting... [7197b50] WIP: TDD and fleshing out unit creation with dbus [fb4e92d] Starting work towards creating/update/delete units - Specifically service units for now. - Using my own version number - Using lombok to reduce builder code. thjomnx#6 (comment)
- Introduced a Struct and Pair class as needed by dbus-java - Updated various versions I am labeling this version as 2.2.0-eks so if this commit is accepted, be sure to remove -eks. --- In a working state. Needed to also use a special struct class for the disableUnitFiles call (+3 squashed commit) Squashed commit: [9dde539] Found that `enableUnitFiles` may perform what I need to get units started. The `List<UnitFileChange>` is not the proper return type. Some research lead me to AgNO3 project that uses a Tuple type of structure to hold the return type: https://github.com/AgNO3/code/blob/main/orchestrator/agent/system/eu.agno3.orchestrator.system.init.systemd/src/main/java/org/freedesktop/systemd1/Manager.java Still experimenting... [7197b50] WIP: TDD and fleshing out unit creation with dbus [fb4e92d] Starting work towards creating/update/delete units - Specifically service units for now. - Using my own version number - Using lombok to reduce builder code. thjomnx#6 (comment)
I have something working with minimal changes to your code base. See PR #7 Basically did some research on the underlying java-dbus and looked at a few scattered examples and found the need to introduce a Struct and Tuple class and use it as a return type to the Since these are live units, I ran tests in my actual code base (not shared on github) and found that it works with the unit files I generate. |
Will comment directly on the PR. |
Sorry for the back-and-forth, I ended up not using lombok. I was considering it when I thought I'd need to make a builder but that is not the case anymore. |
OK, no problem. |
I just recently found your project and it seems to have a great set of API calls for managing and monitoring units and services. However, after searching around, I can't seem to find any functions that help in the creation of new units and services.
I am working on a program that dynamically creates services for systemd to manager and I am hoping to leverage your API for both monitoring, managing and also creating these units. Currently I create the units via a template:
I use
String.format
to create a file called[email protected]
and the%%i
works with the@
aspect of the service unit.Then I run this command to enable it and fire it up:
I have various other code to read the stdout/stderr and also check the exit value, ensuring it returns 0. All that said, is there functionality in your system to create and register services?
If not, I may be interested in extending this ability into your API (if time allows). Do you have a thought on where it would be best to implement this ability? Would you recommend sub classing and/or implementing any particular interfaces in your code to make this happen properly?
The text was updated successfully, but these errors were encountered: