diff options
author | Christopher Baines <mail@cbaines.net> | 2023-09-12 09:39:11 +0100 |
---|---|---|
committer | Christopher Baines <mail@cbaines.net> | 2023-09-12 13:11:00 +0100 |
commit | f5d950e6a93a6530c21e95de3cc9eacc107739d5 (patch) | |
tree | 772c7b9d555a5fd7fd54f201fbdf4611cdfa89bc /scripts | |
parent | e5b92d207a1aa899cb4b340459d4e8d1e7877ee1 (diff) | |
download | nar-herder-f5d950e6a93a6530c21e95de3cc9eacc107739d5.tar nar-herder-f5d950e6a93a6530c21e95de3cc9eacc107739d5.tar.gz |
Use recent changes to trigger the removal of nars
Both when the nar has been removed from the database, and to check if
it should no longer be stored.
Diffstat (limited to 'scripts')
-rw-r--r-- | scripts/nar-herder.in | 30 |
1 files changed, 28 insertions, 2 deletions
diff --git a/scripts/nar-herder.in b/scripts/nar-herder.in index 5222864..6d01f74 100644 --- a/scripts/nar-herder.in +++ b/scripts/nar-herder.in @@ -55,6 +55,7 @@ (logging port-log) (prometheus) (fibers) + (fibers channels) (fibers scheduler) (fibers conditions) (fibers web server) @@ -666,11 +667,36 @@ canonical-storage (assq-ref opts 'storage-limit) metrics-registry - nar-removal-criteria))))) + nar-removal-criteria)))) + (addition-channel (make-channel))) + + (spawn-fiber + (lambda () + (while #t + (match (get-message addition-channel) + (('addition file) + (when mirror-channel + (put-message mirror-channel + `(fetch ,file))) + (when removal-channel + (spawn-fiber + (lambda () + (sleep 60) + (put-message removal-channel + `(remove-from-storage ,file)) + (sleep (* 5 60)) + (put-message removal-channel + `(remove-from-storage ,file)) + (sleep (* 15 60)) + (put-message removal-channel + `(remove-from-storage ,file)) + (sleep 3600) + (put-message removal-channel + `(remove-from-storage ,file)))))))))) (start-recent-change-listener-fiber database - mirror-channel + addition-channel removal-channel)) (log-msg 'DEBUG "finished maintenance setup") |