[SOLVED] systemd service for fancontrol not working

This forum is dedicated to basic help and support :

Ask here your questions about basic installation and usage of Mageia. For example you may post here all your questions about getting Mageia isos and installing it, configuring your printer, using your word processor etc.

Try to ask your questions in the right sub-forum with as much details as you can gather. the more precise the question will be, the more likely you are to get a useful answer

[SOLVED] systemd service for fancontrol not working

Postby mzurhorst » Jan 7th, '15, 23:46

Hi all,
I have configured fancontrol because the fan of my Dell laptop is spinning all the time.
This is working quite well now, and I like to get fancontrol started automatically.

I was reading the man pages and some tutorials, and I thought that I have a tiny "fancontrol.service" file properly created.
However, the service starts, but after a short while, it is stopped for a unknown reason. It seems that systemd tries to restart the broken service, but fails.

Here is my service file. What is wrong with it?

Code: Select all
[Unit]
Description=Fancontrol service

[Service]
Type=forking
ExecStart=/sbin/fancontrol
PIDFile=/var/run/fancontrol.pid

[Install]
WantedBy=multi-user.target


Since /sbin/fancontrol is a shell script, I understood that "forking" is the appropriate type, and that the PID file should be specified as well.
I took the path for the PID file directly from the source code of the fancontrol shell script.

Thanks a lot in advance for your help!

Regards,
Marcus
Last edited by mzurhorst on Jan 25th, '15, 23:50, edited 3 times in total.
mzurhorst
 
Posts: 21
Joined: Jun 3rd, '11, 20:25
Location: Germany

Re: systemd service for fancontrol not working

Postby doktor5000 » Jan 8th, '15, 02:12

Type should probably be "oneshot", you should probably start fancontrol with -D.
Also you didn't post where you put fancontrol.service and output of e.g.
Code: Select all
systemctl status fancontrol.service


Short google search shows up the following related threads:

https://bbs.archlinux.org/viewtopic.php?id=151431
https://forums.opensuse.org/showthread. ... ol-service ( please don't put the service into /usr/lib/systemd, it belongs into /etc/systemd/system/ )
http://forums.fedoraforum.org/showthread.php?t=286160 ( please don't put the service into /usr/lib/systemd, it belongs into /etc/systemd/system/ )
http://superuser.com/questions/786186/f ... -but-exits
Cauldron is not for the faint of heart!
Caution: Hot, bubbling magic inside. May explode or cook your kittens!
----
Disclaimer: Beware of allergic reactions in answer to unconstructive complaint-type posts
User avatar
doktor5000
 
Posts: 18020
Joined: Jun 4th, '11, 10:10
Location: Leipzig, Germany

Re: systemd service for fancontrol not working

Postby doktor5000 » Jan 9th, '15, 18:57

FWIW, for the type, see http://enotty.pipebreaker.pl/2014/10/08 ... emd-units/ for explanations what type to use when.
Cauldron is not for the faint of heart!
Caution: Hot, bubbling magic inside. May explode or cook your kittens!
----
Disclaimer: Beware of allergic reactions in answer to unconstructive complaint-type posts
User avatar
doktor5000
 
Posts: 18020
Joined: Jun 4th, '11, 10:10
Location: Leipzig, Germany

Re: systemd service for fancontrol not working

Postby mzurhorst » Jan 13th, '15, 13:15

Sorry for the delay, I was waiting for a email notification ;)

Ok, let me answer the questions:
1) I created the file fancontrol.service in the folder /etc/systemd/service
2) Then, I activated the service via sudo systemctl --system enable fancontrol.service
(this created a symlink to my file inside /etc/systemd/system/multi-user.target.wants/)
3) When the laptop boots, the fan is silent, but turns to full power after a short while.
This is because the service fails and cannot be restarted. The fancontrol safety mechanism sets the fans to full speed.
4) I cannot find the -D switch for the fancontrol bash script in the man page: http://linux.die.net/man/8/fancontrol
What is this supposed to do? (the switch is accepted, but I tried some other letters, and it seems that the script is not doing any error checking at all)
5) The status output is this:
Code: Select all
[marcus@mzlaptop2 system]$ sudo systemctl -l status fancontrol.service
fancontrol.service - Fancontrol service
   Loaded: loaded (/etc/systemd/system/fancontrol.service; enabled)
   Active: failed (Result: timeout) since Di 2015-01-13 09:44:24 CET; 2h 26min ago
  Process: 854 ExecStart=/sbin/fancontrol (code=exited, status=0/SUCCESS)
Jan 13 09:42:54 mzlaptop2 fancontrol[854]: MINSTOP=60
Jan 13 09:42:54 mzlaptop2 fancontrol[854]: MINPWM=0
Jan 13 09:42:54 mzlaptop2 fancontrol[854]: MAXPWM=255
Jan 13 09:42:54 mzlaptop2 fancontrol[854]: Enabling PWM on fans...
Jan 13 09:42:54 mzlaptop2 fancontrol[854]: Starting automatic fan control...
Jan 13 09:44:24 mzlaptop2 systemd[1]: fancontrol.service operation timed out. Terminating.
Jan 13 09:44:24 mzlaptop2 systemd[1]: Failed to start Fancontrol service.
Jan 13 09:44:24 mzlaptop2 systemd[1]: Unit fancontrol.service entered failed state.
Jan 13 09:44:25 mzlaptop2 fancontrol[854]: Aborting, restoring fans...
Jan 13 09:44:25 mzlaptop2 fancontrol[854]: Verify fans have returned to full speed
[marcus@mzlaptop2 system]$


6) Regarding the type, I was just following the man page. I will check to references and report back in the next days.

Thanks for your help!

Regards,
Marcus
mzurhorst
 
Posts: 21
Joined: Jun 3rd, '11, 20:25
Location: Germany

Re: systemd service for fancontrol not working

Postby doktor5000 » Jan 13th, '15, 19:45

mzurhorst wrote:Sorry for the delay, I was waiting for a email notification ;)

Sadly that's not the forum default and has to be enabled explicitly per-user, for users that have created their account before the default was switched.
Please check viewtopic.php?f=7&t=210 and the linked bugreport for more details.

mzurhorst wrote:4) I cannot find the -D switch for the fancontrol bash script in the man page: http://linux.die.net/man/8/fancontrol
What is this supposed to do? (the switch is accepted, but I tried some other letters, and it seems that the script is not doing any error checking at all)

Probably supposed to daemonize fancontrol, that is fork it and keep it running in background. Actually it was only mentioned in the fedora forum post.
I've quickly glanced over the script and it doesn't support anything except for the first argument ($1) which it expects to be a file. And yes, no error checking/handling is in place apart from checking some things related to the config file.
mzurhorst wrote:5) The status output is this:

Seems it starts too early or a required kernel module is not loaded yet. You may need to enable debugging in the scrippt to find out why it doesn't start.
See the previously mentioned arch linux link on how to fix such timing issues.
Cauldron is not for the faint of heart!
Caution: Hot, bubbling magic inside. May explode or cook your kittens!
----
Disclaimer: Beware of allergic reactions in answer to unconstructive complaint-type posts
User avatar
doktor5000
 
Posts: 18020
Joined: Jun 4th, '11, 10:10
Location: Leipzig, Germany

Re: systemd service for fancontrol not working

Postby winstonteacox » Jan 14th, '15, 20:17

Hi!

I am the one, who described fancontol in the other post and I am watching this thread, because systemd is also unknown territory for me.

But there will be another problem:

lm-sensors detects the sensors in a certain order i.e. assigns a number to each sensor. pwmconfig relies on that numbers. These numbers may change - not often - but mostly after kernel-updates. Then fancontrol won't work anymore, because it doesn't find the sensors.

So - if there is a systemd autostart solution, there will be the problem sometimes, that fancontrol suddenly doesn't work anymore. This is not a systemd problem then. The solution is easy - just run the pwmconfig script again and reboot or start fancontrol manually this time.

cheers,
Bernd
Now after my words of profound wisdom, I'm going back to procrastinating.
User avatar
winstonteacox
 
Posts: 139
Joined: Mar 30th, '11, 16:05
Location: Straubing Germany

Re: systemd service for fancontrol not working

Postby doktor5000 » Jan 14th, '15, 22:05

winstonteacox wrote:lm-sensors detects the sensors in a certain order i.e. assigns a number to each sensor. pwmconfig relies on that numbers. These numbers may change - not often - but mostly after kernel-updates. Then fancontrol won't work anymore, because it doesn't find the sensors.

Fix seems to be explained here, no? https://bbs.archlinux.org/viewtopic.php?id=80012

edit doktor5000: Also later versions of lm_sensors seem to support absolute device paths, amon other things:
http://lists.lm-sensors.org/pipermail/l ... 38971.html
Cauldron is not for the faint of heart!
Caution: Hot, bubbling magic inside. May explode or cook your kittens!
----
Disclaimer: Beware of allergic reactions in answer to unconstructive complaint-type posts
User avatar
doktor5000
 
Posts: 18020
Joined: Jun 4th, '11, 10:10
Location: Leipzig, Germany

Re: systemd service for fancontrol not working

Postby mzurhorst » Jan 14th, '15, 23:24

I have not yet found the time to dig too much deeper.
All I can say is that I have some appealing silence here because I switched the start type to "simple".
mzurhorst
 
Posts: 21
Joined: Jun 3rd, '11, 20:25
Location: Germany

Re: systemd service for fancontrol not working

Postby mzurhorst » Jan 14th, '15, 23:41

Ah, maybe this was too optimistic.
I killed the fancontrol process to test whether or not systemd would restart the script.
This does not happen with "simple".

Is my assumption that systemd restarts the service valid at all?
-- Or is this beyond its responsiblity?
mzurhorst
 
Posts: 21
Joined: Jun 3rd, '11, 20:25
Location: Germany

Re: systemd service for fancontrol not working

Postby doktor5000 » Jan 15th, '15, 00:34

That is not defined via the "Type" option. See the man page for the "Restart" option: http://www.freedesktop.org/software/sys ... rvice.html
It defaults to no so that services are not restarted.
Cauldron is not for the faint of heart!
Caution: Hot, bubbling magic inside. May explode or cook your kittens!
----
Disclaimer: Beware of allergic reactions in answer to unconstructive complaint-type posts
User avatar
doktor5000
 
Posts: 18020
Joined: Jun 4th, '11, 10:10
Location: Leipzig, Germany

Re: systemd service for fancontrol not working

Postby mzurhorst » Jan 23rd, '15, 23:09

I managed to solve this topic ultimately.
Thank you, doktor5000, my assumption was just wrong.

Following your link, I specified the restart behaviour and now it is working properly.
The final unit file looks like this:
Code: Select all
[Unit]
Description=Fancontrol service

[Service]
Type=simple
ExecStart=/sbin/fancontrol
Restart=on-failure

[Install]
WantedBy=multi-user.target

I was never dealing with unit files before, but my first experience is quite positive.
It seems simple, while offering plenty of optional complexities if required.

Regards,
Marcus
mzurhorst
 
Posts: 21
Joined: Jun 3rd, '11, 20:25
Location: Germany


Return to Basic support

Who is online

Users browsing this forum: No registered users and 1 guest

cron