This is actually not a bug. LIRC provides lircd.socket which is the recommended way to start lircd. Using lircd.socket, the socket becomes available at an very early stage, and lircd is started when e. g., irexec.service accesses the socket. In systemd parlance, this is "socket activation", and it resolves the ordering issue described here.
EDIT: Note that the fix described above includes "editing" upstream files like lircd.service. This is basically never the right thing to do siince the file will be overwrtten when lirc is updated, Instead, use the standard systemd mechanism: add files to /etc/systemd/sysem whch overrides the upstream files. OTOH, no new files are needed to resolve this issue, just enable lircd.socket instead of lircd.service
Last edit: Alec Leamas 2017-03-18
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I just tried your solution in Arch (i.e. disable lircd.service, enable lircd.socket and irexec.service, use upstream systemd files). Irexec is started properly and running, however it fails to pick IR events. irw shows events fine, instead. The only way to make irexec pick up the events is to manually restart the service. No error messages are printed to the journal.
If, on the other hand, I override lircd.service and lircd.irexec as in the resolution above (I'm putting overrides in /etc/systemd/system/lircd.service.d/ and /etc/systemd/system/irexec.service.d/, not editing the upstream files, but whatever), irexec works properly from the start.
Any idead what might be causing this? Suggestions to help debug the problem?
Using lircd 0.9.4d.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Disabled irexec.service? why? If it's disabled, how come it works?
EDIT: sorry, misread your post.
Anyway, I don't see this as a bug but rather as a downstream configuration issue. The socket ectivation is pretty well tested, and a actual bugt report against that needs to be more specific.
Last edit: Alec Leamas 2017-03-18
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I have perhaps been able to reproduce this. It happens if lircd is built without systemd support in which case it will not pick up the socket provided by systemd. Of course, this means that lircd needs to be restarted after the /run/lirc/lircd socket is created.
Furthermore, systemd has changed the name of the pkg-config file tested by lirc on build. This means that after updating systemd, lircd by default will be built without systemd support.
I attached a patch to the master branch. Could you possibly apply this to the arch build, and verify that it builds with systemd support? One way is to check in the build logs for the output of the ./configure command which should contain
You have rebuilt and installed the result using that patch...
You have raised the loglevel to 'debug' in lirc_options.conf
You have stopped lircd.service
You have restarted lircd.socket
After this, you start irw and makes some remote keypresses.
Now, the patch adds some debug statements. What happens if you grep for systemd fd in the logs? logs which I presume are available using something like journalctl -b0 /usr/sbin/lircd.
Last edit: Alec Leamas 2017-04-02
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I suspected something like that ;) To summarize, this in not that starting irexec before lircd is doesn't work, it's about that the systemd support is not present in lircd due to upstream systemd changes.
Thanks for reporting! This is a nasty bug giving subtle errors. In a better world there would be a unittest for this.
This is actually not a bug. LIRC provides lircd.socket which is the recommended way to start lircd. Using lircd.socket, the socket becomes available at an very early stage, and lircd is started when e. g., irexec.service accesses the socket. In systemd parlance, this is "socket activation", and it resolves the ordering issue described here.
EDIT: Note that the fix described above includes "editing" upstream files like lircd.service. This is basically never the right thing to do siince the file will be overwrtten when lirc is updated, Instead, use the standard systemd mechanism: add files to /etc/systemd/sysem whch overrides the upstream files. OTOH, no new files are needed to resolve this issue, just enable lircd.socket instead of lircd.service
Last edit: Alec Leamas 2017-03-18
I just tried your solution in Arch (i.e. disable lircd.service, enable lircd.socket and irexec.service, use upstream systemd files). Irexec is started properly and running, however it fails to pick IR events. irw shows events fine, instead. The only way to make irexec pick up the events is to manually restart the service. No error messages are printed to the journal.
If, on the other hand, I override lircd.service and lircd.irexec as in the resolution above (I'm putting overrides in
/etc/systemd/system/lircd.service.d/
and/etc/systemd/system/irexec.service.d/
, not editing the upstream files, but whatever), irexec works properly from the start.Any idead what might be causing this? Suggestions to help debug the problem?
Using lircd 0.9.4d.
Disabled irexec.service? why? If it's disabled, how come it works?
EDIT: sorry, misread your post.
Anyway, I don't see this as a bug but rather as a downstream configuration issue. The socket ectivation is pretty well tested, and a actual bugt report against that needs to be more specific.
Last edit: Alec Leamas 2017-03-18
Sure. Just asking if you have an idea of how to debug it. Since no messages appear in the journal, I'm at a loss.
raise the loglevel...
Both irexec and lircd run with
-Ddebug
, no messages are shown.Just to be clear, here's a step by step reproduction of the problem:
systemctl edit lircd
, then typesystemctl edit irexec
, then typesystemctl daemon-reload
systemctl stop irexec lircd.socket lircd
systemctl start lircd.socket irexec
irexec.lircrc
systemctl status irexec
); I'm attaching the output ofjournalctl -e
inlircd1.log
systemctl restart irexec
systemctl status irexec
); I'm attaching the output ofjournalctl -e
inlircd2.log
.Last edit: Luca De Feo 2017-03-19
Please read the irexec(1) manpage for log file location.
~/.cache/irexec.log
? I have no such file if I use the systemd service.So I switched to starting irexec by hand (still using systemd's lircd.socket). With systemd overrides as before:
systemctl stop lircd.socket lircd
systemctl start lircd.socket
irexec -Ddebug /etc/lirc/irexec.lircrc
Ctrl-C
~/.cache/irexec.log
contains this lone line:irexec -Ddebug /etc/lirc/irexec.lircrc
Ctrl-C
~/.cache/irexec.log
contains now:I have perhaps been able to reproduce this. It happens if lircd is built without systemd support in which case it will not pick up the socket provided by systemd. Of course, this means that lircd needs to be restarted after the /run/lirc/lircd socket is created.
Furthermore, systemd has changed the name of the pkg-config file tested by lirc on build. This means that after updating systemd, lircd by default will be built without systemd support.
I attached a patch to the master branch. Could you possibly apply this to the arch build, and verify that it builds with systemd support? One way is to check in the build logs for the output of the ./configure command which should contain
notably the HAVE_SYSTEMD part. Another way is to check the generated config.h file.
If all is well, could you then verify that everything works without any patching of lthe service files?
Last edit: Alec Leamas 2017-04-01
This is the outuput of configure using the default
PKGBUILD
given by Arch (version 0.9.4d):Changing the source to the master branch, I have
The problem persists, exactly as described in my last message.
Finally, I applied your patch, rebuilt, and got:
but the problem won't go away :/
Some double-checks:
Now, the patch adds some debug statements. What happens if you grep for systemd fd in the logs? logs which I presume are available using something like journalctl -b0 /usr/sbin/lircd.
Last edit: Alec Leamas 2017-04-02
My bad, I had botched my tests. The issue is present in master, but goes away with the patch.
I suspected something like that ;) To summarize, this in not that starting irexec before lircd is doesn't work, it's about that the systemd support is not present in lircd due to upstream systemd changes.
Thanks for reporting! This is a nasty bug giving subtle errors. In a better world there would be a unittest for this.
Fixed in [1b4a17], closing
Related
Commit: [1b4a17]
Thanks to you for looking into this!