On Monday 06 July 2015 12:42 AM, Michael Biebl wrote: >> Thanks. Then I'm doing the right thing here already. > Well, a quick look at /usr/lib/pm-utils/sleep.d/01laptop-mode, > /lib/udev/lmt-udev and /etc/acpi/*/lm_* shows, that you are calling > /usr/sbin/laptop-mode directly instead of triggering laptop-mode.service > > > /lib/udev/lmt-udev also shows, that you are backgrounding the subshell, > that your polling inside a while loop waiting for /usr etc. > All this wouldn't be necessary, if you simply triggered a start request > (e.g. via systemctl --no-block).
Oh!! Thank you Michael. This is working better now. rrs@learner:~$ sudo systemctl status laptop-mode.service ● laptop-mode.service - Laptop Mode Tools Loaded: loaded (/lib/systemd/system/laptop-mode.service; enabled; vendor preset: enabled) Active: active (exited) since Mon 2015-07-06 12:36:30 IST; 15min ago Process: 6085 ExecReload=auto (code=exited, status=0/SUCCESS) Main PID: 4481 (code=exited, status=0/SUCCESS) CGroup: /system.slice/laptop-mode.service ├─4503 /bin/sh /usr/share/laptop-mode-tools/module-helpers/lm-polling-daemon └─6210 sleep 150 Jul 06 12:36:30 learner systemd[1]: Started Laptop Mode Tools. Jul 06 12:37:21 learner systemd[1]: Started Laptop Mode Tools. Jul 06 12:37:59 learner systemd[1]: Started Laptop Mode Tools. Jul 06 12:41:30 learner laptop-mode[5553]: enabled, active [unchanged] Jul 06 12:44:01 learner laptop-mode[5663]: enabled, active [unchanged] Jul 06 12:46:31 learner laptop-mode[5832]: enabled, active [unchanged] Jul 06 12:47:39 learner systemd[1]: Reloaded Laptop Mode Tools. Jul 06 12:49:27 learner laptop-mode[6134]: enabled, active [unchanged] Jul 06 12:49:27 learner systemd[1]: Reloaded Laptop Mode Tools. Jul 06 12:51:31 learner laptop-mode[6209]: enabled, active [unchanged] 12:51 ♒♒♒ ☺ Now the backgrounded module does not get killed. So I updated the .service file to add a ExecReload= condition. This will fill in the equivalent of the udev rules calls that I had been invoking, because there I called "/usr/bin/laptop_mode auto", which is supposed to just kinda reload. rrs@learner:~$ cat /lib/systemd/system/laptop-mode.service [Unit] Description=Laptop Mode Tools [Service] Type=oneshot RemainAfterExit=yes ExecStart=@/usr/sbin/laptop_mode init auto ExecStop=@/usr/sbin/laptop_mode init stop ExecStopPost=@/bin/rm -f /var/run/laptop-mode-tools/enabled ExecReload=@/usr/sbin/laptop_mode auto StandardOutput=tty StandardError=tty [Install] WantedBy=multi-user.target 12:53 ♒♒♒ ☺ And then, now, in /lib/udev/lmt-udev, I have the following, and I'm invoking laptop-mode through systemctl, as you have recommended. rrs@learner:~$ cat /lib/udev/lmt-udev #!/bin/sh -e # /usr is not guaranteed to be mounted when udev starts ( if grep -w "systemd" /proc/1/conn; then systemctl --non-block reload laptop-mode elif [ -e /lib/udev/hotplug.functions ]; then . /lib/udev/hotplug.functions wait_for_file /usr/sbin/laptop_mode exec /usr/sbin/laptop_mode "$@" else file=$1 timeout=$2 [ "$timeout" ] || timeout=120 count=$timeout while [ $count != 0 ]; do [ -e "/usr/sbin/laptop_mode" ] && exec /usr/sbin/laptop_mode "$@" && return 0 sleep 1 count=$(($count - 1)) done mesg "$file did not appear before the timeout!" exit 1 fi ) </dev/null >/dev/null 2>&1 & 12:55 ♒♒♒ ☺ Please just confirm if this is the right approach, and I'll update the changes at other invokers too. BTW, Is this the reliable way to detect if systemd is the active running init ? -- Ritesh Raj Sarraf | http://people.debian.org/~rrs Debian - The Universal Operating System
signature.asc
Description: OpenPGP digital signature