-
Notifications
You must be signed in to change notification settings - Fork 29
Multiple device support using upstart or systemd #14
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
base: master
Are you sure you want to change the base?
Conversation
|
Woah, nice work. |
|
I couldn't figure out how to make a single package that did everything. systemd automatically creating a unit for the sysvinit script is one issue; having a systemd dependency in the udev rules file (which isn't required for systems using upstart or sysvinit) is another. |
|
You can have a choice of requirements in your dependency list, for example: |
|
Fiddling with the Debian package dependencies won't help in this case. Having /etc/init.d/daliserver in the package at the same time as /lib/systemd/system/daliserver-systemd@.service and the udev rule would mean that daliserver would be started with the default arguments by the sysvinit script (trying to drive the first device it found) and would also be started with appropriate arguments to -u for each DALI USB device attached to the system. The ordering of what would happen here is not well-defined, and at least one of those invocations of daliserver would fail. |
|
Good point - I came to the same conclusion after contemplating it a bit. |
|
If you can figure out how to make it work, go ahead. What questions would debconf ask, and what would it do after they were answered? |
|
My suggestion is something like this:
If selecting yes, it could then ask for the port or something. |
|
I think that question is pointless because the answer will universally be "yes" - and then on a sysvinit system you would have to say "sorry, not possible". |
Alters the Debian packaging rules to generate three separate binary packages: daliserver, daliserver-upstart and daliserver-systemd. The daliserver package is unchanged, i.e. it contains the debhelper-generated sysvinit startup script. The daliserver-upstart package has an upstart configuration file. This configuration file runs an instance of daliserver when a DALI USB device is plugged in, and stops it when the device is unplugged. A lookup table in /etc/default/daliserver-upstart enables daliserver options to be set based on the serial number of the device that is plugged in. The daliserver-systemd package has a systemd unit template file and a udev rule that runs an instance of daliserver when a DALI USB device is plugged in, and stops it when the device is unplugged. A lookup table in /etc/default/daliserver-systemd enables daliserver options to be set based on the serial number of the device that is plugged in. A helper script in /usr/lib/daliserver-systemd looks up the serial number, bus number and device number based on the systemd template instance name.
Useful references: - systemd/systemd#7109 - systemd/systemd#10321 - systemd/systemd@dcebc9b Quick summary: there are still escaping-related misfeatures in systemd that can't be worked around using systemd-escape. For our particular use-case, @poettering has implemented a workaround that happens to do what we want; this commit switches over to using it (although this introduces a requirement that we use systemd version 236 or later). The general case is still broken.
1ab1742 to
35214dc
Compare
|
I've updated this pull request: I've rebased to current master, and I've fixed an escaping-related issue that stopped the systemd support working sometime after systemd release 229. See systemd#7109 and systemd#10321 for details. |
|
Hi @sde1000 , I just pushed a new branch that adds a basic systemd unit. Once that's merged, we can revisit your proposal of multi-device support. With only a systemd unit in place, I think it would be much simpler to just document how to create multiple versions of the unit that match different USB adapters, and configure the TCP port in each of them statically. I'd also drop /dev/default/daliserver in this case. |
|
I'm using systemd; I think I'm still using packages generated according to this pull request. |
The creation of a Another option would be to ship |
|
The systemd.unit man page says that an empty unit (size 0) is also treated as masked. In lack of a better (read: more modern) approach, I'm inclined to accept your proposal of using /etc/default/daliserver to map device serial numbers to TCP ports, however I'd like to have some modifications to the PR:
I get that producing journals based on the unit instances (which may not have persistent IDs) is somewhat suboptimal, but I really don't like log files if they can be avoided. It would be perfect if we could use the serial number as instance ID instead, but libusb doesn't make it easy to filter by device attributes without opening each device. Please let me know if you'd prefer that I make these modifications myself instead, I'll rebuild the PR in that case. |
This is a re-work of my earlier pull request (now closed) regarding startup scripts for systems that need to support more than one DALI USB device being plugged in at a time, with stable mapping between physical device and TCP port number.
This pull request alters the Debian packaging rules to generate three separate binary packages: daliserver, daliserver-upstart and daliserver-systemd.
The daliserver package is unchanged, i.e. it contains the sysvinit startup script.
The daliserver-upstart package has an upstart configuration file. This configuration file runs an instance of daliserver when a DALI USB device is plugged in, and stops it when the device is unplugged. A lookup table in /etc/default/daliserver-upstart enables daliserver options to be set based on the serial number of the device that is plugged in.
The daliserver-systemd package has a systemd unit template file and a udev rule that runs an instance of daliserver when a DALI USB device is plugged in, and stops it when the device is unplugged. A lookup table in /etc/default/daliserver-systemd enables daliserver options to be set based on the serial number of the device that is plugged in. A helper script in /usr/lib/daliserver-systemd looks up the serial number, bus number and device number based on the systemd template instance name.