diff options
-rw-r--r-- | scripts/mumi.in | 60 |
1 files changed, 36 insertions, 24 deletions
diff --git a/scripts/mumi.in b/scripts/mumi.in index 81cb887..82e2319 100644 --- a/scripts/mumi.in +++ b/scripts/mumi.in @@ -28,15 +28,39 @@ (ice-9 match) (ice-9 threads) (mumi config) + (mumi bugs) (mumi messages) (mumi web server) (debbugs)) +(db-create!) + (define %default-repl-server-port ;; Default port to run REPL server on, if --listen-repl is provided ;; but no port is mentioned 37146) +;; Keep indexing the mail directory +(define %update-interval 60) +(define mu-index + (let ((mu (%config 'mu-executable))) + (lambda _ + (let* ((maildir (%config 'mail-dir)) + (args (list "index" + "--quiet" + (format #f "--muhome=~a" maildir) + (format #f "--maildir=~a" maildir)))) + (unless (zero? (apply system* mu args)) + (format (current-error-port) + "Failed to run `~a'~%" command)))))) + +(define update-state! + (lambda _ + (mu-index) + (update-bug-database!) + (sleep %update-interval) + (update-state!))) + (define %options ;; Specifications of the command-line options (list (option '("listen-repl") #f #t @@ -49,12 +73,16 @@ (error "invalid REPL server port" arg))))) (option '("fetch") #f #f (lambda (opt name arg result) - (alist-cons 'fetch #t result))))) + (alist-cons 'fetch #t result))) + (option '("worker") #f #f + (lambda (opt name arg result) + (alist-cons 'worker #t result))))) (define %default-options ;; Alist of default option values `((listen-repl . #f) - (fetch . #f))) + (fetch . #f) + (worker . #f))) (define (parse-options args) (args-fold @@ -67,6 +95,8 @@ (let ((opts (parse-options (cdr (program-arguments))))) (cond + ((assoc-ref opts 'worker) + (update-state!)) ((assoc-ref opts 'fetch) (let ((bug-nums (sort (append-map (lambda (package) @@ -92,25 +122,7 @@ (else (let ((repl-port (assoc-ref opts 'listen-repl))) (when repl-port - (spawn-server (make-tcp-server-socket #:port repl-port))))))) - -;; Keep indexing the mail directory -(define %mu-index-interval 30) -(define mu-index - (let ((mu (%config 'mu-executable))) - (lambda _ - (let* ((maildir (%config 'mail-dir)) - (args (list "index" - "--quiet" - (format #f "--muhome=~a" maildir) - (format #f "--maildir=~a" maildir)))) - (unless (zero? (apply system* mu args)) - (format (current-error-port) - "Failed to run `~a'~%" command)) - (alarm %mu-index-interval))))) -(sigaction SIGALRM mu-index 0) -(mu-index) - -(use-modules (mumimu)) -(mu:initialize (%config 'mail-dir)) -(start-mumi-web-server 1234) + (spawn-server (make-tcp-server-socket #:port repl-port)))) + (use-modules (mumimu)) + (mu:initialize (%config 'mail-dir)) + (start-mumi-web-server 1234)))) |