Add scheduler, rate limiting and headless mode.

Hard-coded 60s URL and 10s host floors with jitter and per-host
backoff, shared between dibs processes through a locked state file.
The scheduler shuffles due URLs each round and runs one worker per
host; 'dibs --headless' watches and logs JSON.
This commit is contained in:
Overlord committed 2026-10-14 09:04:15 +02:00
1 parent bb010356a0
commit 2175c0e5aa
30 files changed
+1434 -126

No files matched your search

+26
View File
@@ -0,0 +1,26 @@
package fsutil
import (
"os"
"path/filepath"
)
// Lock takes an exclusive lock on path, creating it if needed, and blocks
// until it gets it. The lock is shared with other processes. The returned
// function releases it.
func Lock(path string) (func(), error) {
if err := os.MkdirAll(filepath.Dir(path), 0o700); err != nil { return nil, err }
f, err := os.OpenFile(path, os.O_RDWR|os.O_CREATE, 0o600)
if err != nil { return nil, err }
if err := lockFile(f); err != nil {
_ = f.Close()
return nil, err
}
return func() {
_ = unlockFile(f)
_ = f.Close()
}, nil
}