Coder Social home page Coder Social logo

faljse / sdnotify Goto Github PK

View Code? Open in Web Editor NEW
58.0 58.0 18.0 63 KB

SDNotify implements the systemd notification protocol in Java.

License: GNU Lesser General Public License v2.1

Java 100.00%
daemon java linux notification-protocol service-management systemd unix watchdog

sdnotify's People

Contributors

faljse avatar flaktack avatar nothub avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

sdnotify's Issues

Feature request: make determinePid() public

I think it's beneficial if users of the library have a consistent way of sending the process PID to SystemD which is consistent with the check in determinePid().equals(watchdog_pid)

Fail to startup 1.2

Hello,

Unfortunately, it seems like 1.2 won't start for us. Here is the relevant piece of stacktrace :

Caused by: java.lang.Error: Structure.getFieldOrder() on class info.faljse.SDNotify.jna.CLibrary$SockAddr returns names ([addr, family]) which do not match declared field names ([addr])
at com.sun.jna.Structure.getFields(Structure.java:1027)
at com.sun.jna.Structure.deriveLayout(Structure.java:1172)
at com.sun.jna.Structure.calculateSize(Structure.java:1097)
at com.sun.jna.Structure.calculateSize(Structure.java:1049)
at com.sun.jna.Structure.allocateMemory(Structure.java:403)
at com.sun.jna.Structure.<init>(Structure.java:194)
at com.sun.jna.Structure.<init>(Structure.java:182)
at com.sun.jna.Structure.<init>(Structure.java:169)
at com.sun.jna.Structure.<init>(Structure.java:161)
at info.faljse.SDNotify.jna.CLibrary$SockAddr.<init>(CLibrary.java:70)
at info.faljse.SDNotify.SDNotify.<init>(SDNotify.java:46)
at info.faljse.SDNotify.SDNotify.getInstance(SDNotify.java:184)
at info.faljse.SDNotify.SDNotify.isAvailable(SDNotify.java:59)
...

If that's any help : the OS is CentOS Linux release 7.5.1804, kernel is 3.10.0-862.11.6.el7.x86_64.

Cheers

Abstract UNIX domain socket support

First of all, thank you for this library!

I have a question/potential issue with systemd version 208

It seems my platform exposes notify socket like so:

u_dgr  UNCONN     0      0      @/org/freedesktop/systemd1/notify 7815                  * 0       users:(("systemd",1,7))

Which means that this is abstract UNIX domain socket

In my app: SystemdNotify.ready("some info") fails with (stack edited):

com.sun.jna.LastErrorException: [107] Transport endpoint is not connected
        at info.faljse.SDNotify.jna.CLibrary.send(Native Method)
        at info.faljse.SDNotify.io.NativeDomainSocket.send(NativeDomainSocket.java:58)
        at info.faljse.SDNotify.SDNotify.sendString(SDNotify.java:193)
        at info.faljse.SDNotify.SDNotify.sendNotify(SDNotify.java:70)

I have a suspicion that the @ character should by manually swapped into NULL byte before using here:

            CLibrary.SockAddr sockAddr = new CLibrary.SockAddr(socketName);
            sd = new NativeDomainSocket();
            sd.connect(sockAddr);

Could you confirm it is indeed an issue?

If not, could you help me understand the problem with [107] Transport endpoint is not connected?

Project should run with JDK 1.8 but uses a method from JDK 9

The Project is supposed to run with jdk 1.8 but it uses a method which is marked @since 9
and therefore doesn't really work on jdk 1.8, see Stacktrace below:

        <maven.compiler.source>1.8</maven.compiler.source>
        <maven.compiler.target>1.8</maven.compiler.target>
Exception in thread "main" java.lang.NoSuchMethodError: java.util.List.of(Ljava/lang/Object;Ljava/lang/Object;)Ljava/util/List;
  at info.faljse.SDNotify.jna.CLibrary$SockAddr.getFieldOrder(CLibrary.java:81)
  at com.sun.jna.Structure.fieldOrder(Structure.java:1044)
  at com.sun.jna.Structure.getFields(Structure.java:1098)
  at com.sun.jna.Structure.deriveLayout(Structure.java:1265)
  at com.sun.jna.Structure.calculateSize(Structure.java:1192)
  at com.sun.jna.Structure.calculateSize(Structure.java:1144)
  at com.sun.jna.Structure.allocateMemory(Structure.java:426)
  at com.sun.jna.Structure.<init>(Structure.java:216)
  at com.sun.jna.Structure.<init>(Structure.java:204)
  at com.sun.jna.Structure.<init>(Structure.java:191)
  at com.sun.jna.Structure.<init>(Structure.java:183)
  at info.faljse.SDNotify.jna.CLibrary$SockAddr.<init>(CLibrary.java:75)
  at info.faljse.SDNotify.SDNotify.<init>(SDNotify.java:48)
  at info.faljse.SDNotify.SDNotify.getInstance(SDNotify.java:186)
  at info.faljse.SDNotify.SDNotify.sendNotify(SDNotify.java:72)

String encoding is not correct

According to comment

* Passes a single-line UTF-8 status string back to the service manager that describes the service state.

the string sent to SystemD is encoded in UTF-8 but according to line
sd.send(s.getBytes(StandardCharsets.US_ASCII), s.length());

the encoding used is US-ASCII.

I think the encoding should be adjusted to UTF-8 because of the SystemD expectation being UTF-8 (as correctly stated in the comment) which is also documented in https://www.freedesktop.org/software/systemd/man/sd_notify.html

Package systemdnotify not found

The README mentions import info.faljse.systemdnotify.SDNotify, but this leads to an error message claiming the systemdnotify package cannot be found. Should it be changed to say import info.faljse.SDNotify.SDNotify, which seems to work, instead?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.