NTP start question

elorimer

Very Senior Member
I moved my main setup from an AC86 to an AX88, which seems to boot much faster. I have a lot of addons, including diversion. Part of my setup is a nonstandard scribe install that depends on ntp having synced (I'll explain below). That worked fine on the AC86 but not on the AX88, because it seems to start before ntp syncs. So I inserted an ntp hold as part of my startup (the normal hold, without a lock file but with an escape loop). Then it worked fine.

I sort of vaguely assumed that entware didn't start until ntp syncs, but I see that a more than a few addons have ntp checks. I get that if ntp has synced the addon will immediately go on its merry way, but some wait 30 seconds for the next check, I think. So there could be several addons waiting during the boot process before they actually start.

So I'm wondering if there should be a straight off single check/wiat for all the addons, and where in the hooks it should be. Or, maybe there is?

TL;DR

The standard scribe install appends the starting log to the messages file. I like to see the messages file as a single file with the current boot and a proper timestamp. I never feel the need to go back to older messages files, but I do want to see what might have been logged before the router rebooted. So my scribe starting sequence is to copy the current messages file to a new beforeboot.log file, write a "Start boot" to a new messages file; then copy the current syslog.log to a startup.log file, start syslog-ng, and then as the very first thing process the startup.log file with a timestamp of when it is processed. At that point the startup.log file is about 1200 lines. If ntp has synced, I end up with a beforeboot.log file, and a messages file that starts with "Start boot" and then all the logged messages generated from the boot on, with a current timestamp. So I can see other scripts waiting.
 

ColinTaylor

Part of the Furniture
I never feel the need to go back to older messages files, but I do want to see what might have been logged before the router rebooted.

I don't understand why you're using Scribe at all. Why not uninstall it and use the normal router syslog?
 

elorimer

Very Senior Member
I don't understand why you're using Scribe at all. Why not uninstall it and use the normal router syslog?
Sifting the log into buckets I'm less interested in. But also, five other sytems logging here too; easier to follow..
 

ColinTaylor

Part of the Furniture
So I'm wondering if there should be a straight off single check/wiat for all the addons, and where in the hooks it should be. Or, maybe there is?
IIRC someone (probably @dave14305) posted a few lines of code way back (based on the ntp_ready nvram variable) that did a check/wait for NTP. I think most of the script writers use this code or something similar tailored to their own needs. I can't see any particular advantage to having a dependency on some common external script that performs this function as it's literally three or four lines of code.
 

dave14305

Part of the Furniture
I once proposed a hook for NTP sync but it didn’t go anywhere.
I ended up hooking into restart_diskmon as a signal that NTP was synced for my Unbound script.
 

elorimer

Very Senior Member
IIRC someone (probably @dave14305) posted a few lines of code way back (based on the ntp_ready nvram variable) that did a check/wait for NTP. I think most of the script writers use this code or something similar tailored to their own needs. I can't see any particular advantage to having a dependency on some common external script that performs this function as it's literally three or four lines of code.
14 lines, without the lock files. So, at startup, several scripts are all sitting around waiting with the same code. Not sure how many.
 

thelonelycoder

Part of the Furniture
Maybe this is why I don't use add-on scripts other than the ones I've written for myself. :D
Yeah, we all know that you‘re a good coder and a great analyser of things that go wrong on our routers :):cool: .
But writing code for one’s own single setup OR writing the same functionality for all models and configurations out there is an entirely different matter.
Just stating the obvious :cool:
 

Mogsy

Regular Contributor
Sorry off topic. While we are talking about ntp. Is it better to redirect all ntp to ntpmerlin or doesnt matter?
 

ColinTaylor

Part of the Furniture
But writing code for one’s own single setup OR writing the same functionality for all models and configurations out there is an entirely different matter.
Just stating the obvious :cool:
I completely agree. My post was mostly made as a joke. It wasn't intended as a criticism of any script writers. Apologies to them if it sounded that way. But on a more serious note, I was trying to highlight the different requirements or use cases that different scripts have. I find it difficult to see how all these requirements could be met in an external script/function without it ending up being more complex and potentially more brittle than the current solutions.

The proposal referred to by Dave in post #5 appears to be something different again (and not what I was originally thinking of). There he appears to be suggesting a brand new event triggered by NTP being set. So various scripts would never run until that was the case. It probably makes sense for the Unbound example he cites. For my own scripts I don't have such a requirement. I have a couple of scripts where it's nice if the date/time is set correctly but it's not a necessity. If the date/time isn't set after 30 seconds they carry on, I would not want them to not run at all.
 

elorimer

Very Senior Member
I ended up hooking into restart_diskmon as a signal that NTP was synced for my Unbound script.
What I've done without intending to is hold up all entware scripts for up to 5 minutes until ntp syncs and syslog-ng starts (S01). So I don't really need the more standard NTP wait built into Unbound, which also holds any later entware script for up to 5 minutes.

But at the same time, outside Entware, Skynet is running its 10 minute clock, and UIScribe has its 5 minute clock running (which means I might have a race condition). Scmerlin, spdmerlin and dn-vnstat each have its 10 minute clock running.

I follow that each should check that ntp has synched, and some need a lock file. I'm just wondering if there should be one thing, maybe built into the amtm install routine, to rule all of these.
 

SomeWhereOverTheRainBow

Part of the Furniture
I once proposed a hook for NTP sync but it didn’t go anywhere.
I ended up hooking into restart_diskmon as a signal that NTP was synced for my Unbound script.
I am seeing what @RMerlin thinks about it now, He might have had some time to come up with some ideas.
 

Similar threads

Latest threads

Sign Up For SNBForums Daily Digest

Get an update of what's new every day delivered to your mailbox. Sign up here!
Top