thjomnx / java-systemd Goto Github PK
View Code? Open in Web Editor NEWJava access to systemd via D-Bus
License: Other
Java access to systemd via D-Bus
License: Other
Hey Markus,
This issue is question, so feel free to close it if you wish. I noticed that you have a bunch of code which seems to be maintained manually. Yet looking at it amount I believe first portion could be generated few years back. Was it a case? Can you recommend any code generator which actually works?
Generator I found in dbus-java produces incomplete results.
Thanks,
Łukasz
In ManagerInterface there is some methods that returns a Tuples
Ex: EnableUnitFiles, ReenableUnitFiles, PresetUnitFiles etc.
This doesn't work in current version and throws an exception when trying to map the result back to List
There exists a similar function reenableUnitFiles that returns List but that also fails to run.
@DBusMemberName(value = "EnableUnitFiles")
List<UnitFileChange> enableUnitFiles(List<String> names, boolean runtime, boolean force);
The return signature for this functions is ba(sss) so it should probably be changed to something like:
PairTuplet<Boolean, List<UnitFileChange>> enableUnitFiles(List<String> names, boolean runtime, boolean force);
Where PairTuplet extends Tuplet.
For some reason it seems only to work when using parameterized typed class otherwise it would probably only need to change to:
UnitFileInstallChange enableUnitFiles(List<String> names, boolean runtime, boolean force);
And that UnitFileInstallChange holds an List of UnitFileChanges instead of only one UnitFileChanges as it is today. But we didn't get that one to work.
Thank you very much for creating this nice library!
As I am a Java noob, I haven't found a way to change the log level of the library.
Could you point that out to me?
Cheers,
Valentin
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:
[Unit]
Description=Transcoding StreamID %%i
[Service]
ExecStart=/bin/echo TEST %1$s/%%i :: Random num: %2$s
User=%1$s
Restart=always
RestartSec=3
StandardOutput=journal+console
StandardError=journal+console
SyslogIdentifier=transcoding_streamid_%%i
[Install]
Alias=transcoding-streamid-%%i
WantedBy=multi-user.target
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:
new ProcessBuilder()
.command("sudo", "systemctl", "enable", "--now", serviceFile.getPath())
.redirectErrorStream(true)
.start();
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?
With the latest major release of dbus-java (v5.0.0), Systemd.get().getManager() fails with:
java.lang.NoSuchMethodError: org/freedesktop/dbus/connections/impl/DBusConnection.getConnection(Lorg/freedesktop/dbus/connections/impl/DBusConnection$DBusBusType;)Lorg/freedesktop/dbus/connections/impl/DBusConnection; (loaded from xxxxxxx/org.freeedesktop.dbus.5.0.jar by org.eclipse.osgi.internal.loader.EquinoxClassLoader@99aa01a5[org.freeedesktop.dbus:5.0.0(id=183)]) called from class de.thjom.java.systemd.Systemd (loaded from xxxxxxxxx/de.thjom.java.systemd.2.1.jar by org.eclipse.osgi.internal.loader.EquinoxClassLoader@3fb8805f[de.thjom.java.systemd:2.1.0(id=204)]).
de.thjom.java.systemd.Systemd.open(Systemd.java:164)
de.thjom.java.systemd.Systemd.get(Systemd.java:116)
de.thjom.java.systemd.Systemd.get(Systemd.java:105)
...
Apparently the DBusConnection.getConnection(DBusConnection.DBusBusType.SYSTEM)
method has been removed.
I had the same issue with some low-level code which uses dbus-java directly, and it worked by using:
DBusConnection dBusConnection = DBusConnectionBuilder.forSystemBus().build()
instead.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.