Merge pull request #716 from pi-hole/new/DELAY_STARTUP

Add DELAY_STARTUP setting to delay startup of the embedded dnsmasq
This commit is contained in:
DL6ER
2020-03-29 23:23:02 +02:00
committed by GitHub
5 changed files with 32 additions and 1 deletions
+13
View File
@@ -358,6 +358,19 @@ void read_FTLconf(void)
else
logg(" CNAME_DEEP_INSPECT: Inactive");
// DELAY_STARTUP
// defaults to: zero (seconds)
buffer = parse_FTLconf(fp, "DELAY_STARTUP");
config.delay_startup = 0;
if(buffer != NULL && sscanf(buffer, "%u", &config.delay_startup) &&
(config.delay_startup > 0 && config.delay_startup <= 300))
{
logg(" DELAY_STARTUP: Requested to wait %u seconds during startup.", config.delay_startup);
}
else
logg(" DELAY_STARTUP: No delay requested.");
// Read DEBUG_... setting from pihole-FTL.conf
read_debuging_settings(fp);
+1
View File
@@ -21,6 +21,7 @@ typedef struct {
int DBinterval;
int port;
int maxlogage;
unsigned int delay_startup;
int16_t debug;
unsigned char privacylevel;
unsigned char blockingmode;
+15
View File
@@ -13,6 +13,8 @@
#include "memory.h"
#include "config.h"
#include "log.h"
// sleepms()
#include "timers.h"
void go_daemon(void)
{
@@ -126,3 +128,16 @@ char *getUserName(void)
return name;
}
void delay_startup(void)
{
// Exit early if not sleeping
if(config.delay_startup == 0u)
return;
// Sleep if requested by DELAY_STARTUP
logg("Sleeping for %d seconds as requested by configuration ...",
config.delay_startup);
sleep(config.delay_startup);
logg("Done sleeping, continuing startup of resolver...\n");
}
+1
View File
@@ -14,5 +14,6 @@ void go_daemon(void);
void savepid(void);
char * getUserName(void);
void removepid(void);
void delay_startup(void);
#endif //DAEMON_H
+2 -1
View File
@@ -82,7 +82,8 @@ int main (int argc, char* argv[])
// immediately before starting the resolver.
check_capabilities();
// Start the resolver
// Start the resolver, delay startup if requested
delay_startup();
startup = false;
main_dnsmasq(argc_dnsmasq, argv_dnsmasq);