Better request interval

This commit is contained in:
Bob Wen 2021-01-29 11:45:41 +08:00
parent 28825aaebc
commit 06d6ed87c0
1 changed files with 2 additions and 2 deletions

View File

@ -102,13 +102,13 @@ get_time_delta = (url) ->
for i in [1 .. argv.count]
step = "\##{i}: ".padStart 8
for retry in [0 .. argv.retry]
start_at = Date.now()
try
r = await get_server_time url
server_moment = + dayjs r.headers.date
catch e
console.log "#{step}#{e}"
if r?.timings?
await delay argv.interval + r.timings.start - Date.now()
await delay argv.interval + start_at - Date.now()
if r?.timings? and server_moment?
break
continue if not server_moment?