Error in /var/log/pihole_updateGravity.log

changed test into

	FTL_pid=$(pidof ${resolver})
	FTL_pid2=$(pgrep -f ${resolver})
	echo "FTL pid with pidof (/opt/pihole/gravity.sh): ${FTL_pid}"
	echo "FTL pid with pgrep (/opt/pihole/gravity.sh): ${FTL_pid2}"

output:

  [i] Swapping databases...
e[K  [✓] Swapping databases
  [i] Number of gravity domains: 2180799 (1573528 unique domains)
  [i] Number of exact blacklisted domains: 0
  [i] Number of regex blacklist filters: 34
  [i] Number of exact whitelisted domains: 44
  [i] Number of regex whitelist filters: 2
FTL pid with pidof (/usr/local/bin/pihole): 18055
FTL pid with pgrep (/usr/local/bin/pihole): 18055
path: /usr/bin:/bin:/usr/local/bin/
choice: killall
  [i] Cleaning up stray matter...
e[K  [✓] Cleaning up stray matter
FTL pid with pidof (/opt/pihole/gravity.sh): 
FTL pid with pgrep (/opt/pihole/gravity.sh): 18055
FTL pid with pidof (/usr/local/bin/pihole): 
FTL pid with pgrep (/usr/local/bin/pihole): 18055
path: /usr/bin:/bin:/usr/local/bin/
choice: service
  [✗] /usr/local/bin/pihole: line 138: service: command not found

  [✓] DNS service is running

One step closer to the cause of using service.
This doesn't change the fact the script cannot find service, due to the missing /usr/sbin.

edit
bad copy/paste, corrected
/edit

Oh wow, this is an interesting find.

But this makes more sense now, right? The fallback isn't needed when pidof isn't failing making this bug appear less (if at all).

Why -f ? Looking at the man page what -f does, this doesn't make much sense to me. We do not want to search through the path.

It's the option that was recommended on one side, reporting about pidof not finding the PID :sweat_smile:

I checked the man before posting here and

       -f, --full
              The pattern is normally only matched against the process name.  When -f is set, the full command line is used.

didn't sound bad if we wan't to find a PID which might be hard to capture. But without -f might work as well.

I agree that we should swap pidof + kill entirely with pkill. And, yes, also adjust the PATH :wink:

Special thanks to @jpgpi250 and @yubiuser for nailing this down and discovering the real issue (pidof failing) which was initially hidden behind another one (service failed to run even when it should not have been used in the first place).

1 Like

Thank you for making these changes.

One quick question: pidof is also used in gravity.sh. Since pidof appears to be unreliable, why isn't this also changed into pgrep? As indicated in the test results, it also fails to provide the correct result in that script.

Thanks to all users and developers, who have contributed to solve this problem...

1 Like

For the sole reason of having missed this spot. Done now. Thanks.

SORRY...………

file advanced/Templates/pihole-FTL.service

looks like you can also remove the line

PIDFILE=/run/pihole-FTL.pid

PIDFILE is only used in the section you are removing (avoid confusion in the near future).

edit
applied all 4 changed files to my system, no problems detected (ran pihole -g, updategravity, using cron, sudo service pihole-FTL - all options tested and pihole restartdns - all options tested)
/edit

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.