vmatare / thinkfan

The minimalist fan control program
GNU General Public License v3.0
541 stars 62 forks source link

Auto-start not working, however starting manually works #150

Closed metamacro closed 2 years ago

metamacro commented 3 years ago

thinkfan.service sometimes doesn't start on boot, however starting it manually always works. In other words, the file /proc/acpi/ibm/thermal sometimes causes problems on boot. Happens for both thinkfan and thinkfan-git from the AUR. System info: P14s AMD Gen 2 - Ryzen 7 PRO 5850U, Arch 5.13.12

> sudo systemctl status thinkfan.service
× thinkfan.service - simple and lightweight fan control program
     Loaded: loaded (/usr/lib/systemd/system/thinkfan.service; enabled; vendor preset: disabled)
    Drop-In: /etc/systemd/system/thinkfan.service.d
             └─override.conf
     Active: failed (Result: exit-code) since Fri 2021-08-27 22:15:34 CEST; 19s ago
    Process: 394 ExecStart=/usr/bin/thinkfan $THINKFAN_ARGS (code=exited, status=1/FAILURE)
        CPU: 8ms

Aug 27 22:15:34 sladoled systemd[1]: Starting simple and lightweight fan control program...
Aug 27 22:15:34 sladoled thinkfan[394]: ERROR: /proc/acpi/ibm/thermal: No such file or directory
Aug 27 22:15:34 sladolRestart=on-failure
RestartSec=5sRestart=on-failure
RestartSec=5sed systemd[1]: thinkfan.service: Control process exited, code=exited, status=1/FAILURE
Aug 27 22:15:34 sladoled systemd[1]: thinkfan.service: Failed with result 'exit-code'.
Aug 27 22:15:34 sladoled systemd[1]: Failed to start simple and lightweight fan control program.

/etc/thinkfan.yaml

sensors:
  - tpacpi: /proc/acpi/ibm/thermal
    indices: [0]

fans:
  - tpacpi: /proc/acpi/ibm/fan

levels:
  - ["level 2", 0, 50]
  - ["level 4", 45, 60]
  - ["level auto", 55, 75]
  - ["level disengaged", 70, 255]

I've found a workaround. If it doesn't manage to get loaded on the first try it succeeds on the second, by adding the following lines to the [Service] section of the unit file /usr/lib/systemd/system/thinkfan.service.

Restart=on-failure
RestartSec=5s

A more elegant workaround was to add the following under the [Service] section:

ExecStartPre=/bin/sleep 5

Adding Wants/After for proc-acpi-ibm-thermal to the [Unit] sectiondidn't fix the issue.

vmatare commented 3 years ago

I've seen a bunch of these issues come up over the years now. But every time I conclude that (1) implementing a clean workaround for this in thinkfan itself is non-trivial and (2) it's not really thinkfan's responsibility. A driver module isn't ready when it should be, so this is an issue of dependency management in the service manager. I'm currently depending on sysinit.target and modules-load.service, but apparently that's not enough. When looking through systemd.special (7), there really doesn't seem to be anything that would more explicitly indicate whether hardware monitoring is ready.

tl;dr: Been going back and forth on whether & how to fix this in thinkfan

metamacro commented 3 years ago

Thank you for the detailed answer! In case I manage to find an answer I'll get back to you. Should I close the issue?

vmatare commented 3 years ago

duplicate of #118 basically...

vmatare commented 3 years ago

Thank you for the detailed answer! In case I manage to find an answer I'll get back to you. Should I close the issue?

I think we can just leave this open so people looking for a solution to this problem can find it easily.

vmatare commented 2 years ago

fix is in development at https://github.com/vmatare/thinkfan/tree/init_retries and slated for the 2.0 release

vmatare commented 2 years ago

Hi @andreiosg, this should be fixed in master now with a new config setting: https://github.com/vmatare/thinkfan/issues/189#issuecomment-1196011925

metamacro commented 2 years ago

Hi, awesome, thanks for the heads up! ^^