Separate startup delay and the delay after reboot

TLDR: add a separate entry in the config to prevent FTL from starting too early before all of the network interfaces are ready.

Some users on Reddit (including myself) found that DNS is not responding when the pi reboots. Upon further investigation, it seems that the issue is caused by a "race condition". Pi-hole might start before the network interfaces are ready, so pihole does not accept the DNS queries received on those interfaces even if they are ready.

The current solution is to add a DELAY_STARTUP=10 in the FTL config, which makes sure the interfaces are ready before FTL starts.

This works great, but the issue is FTL sleeps for that 10 seconds even when it was told to restart by admin page or cli, long after the reboot, waiting for an unnecessary 10 seconds.

I suggest adding a separate delay for the delay after boot. This could be achieved by setting a flag every time the pi shutdown. If the flag is there then wait for the additional delay.

It's not clear what you want to change. The startup delay specifically applies to FTL, which is why it is delaying startup per the settings you have applied.

How should FTL distinguish that it was started right after boot from "long after boot"?

TLDR: add a separate entry in the config to prevent FTL from starting too early before all of the network interfaces are ready.

The current one kicks in whenever FTL starts. The request is hoping to add a separate delay that ONLY kicks in during the first FTL startup after boot/reboot. Any startup/restart of FTL wont use that delay.

Set a flag in a directory where the OS will clear it every (re)boot?

If the flag is not present then use that delay and set the flag.

Or use the uptime -p command and check if it is in the first X minutes.

cut -f1 -d. /proc/uptime gives the uptime in seconds.

The X may be configurable

All these suggestions seem really hacky and dirty.

This sparks another idea: We could maybe wait for a given (= one) interface to become ready and only delay if it isn't there. Just thinking out aloud, this may have other side-effects. Opinions welcome.

This is also a good solution, but what if something went wrong and the interface never comes up?

For example, someone uses wifi to connect the pi. Now they replaces the router and got a free ethernet port, so they decided to use ethernet and block wlan0. If they forgot to change pihole config then FTL would never starts. Maybe add a timeout of 2 minutes?

Or, wait until it can ping the gateway? Or allow multiple interfaces to be monitored, any one comes up would pass the check?