From: ludo@gnu.org (Ludovic Courtès)
To: Danny Milosavljevic <dannym@scratchpost.org>
Cc: 33265@debbugs.gnu.org
Subject: [bug#33265] [WIP RFC v4] services: Add file system monitoring service.
Date: Sat, 10 Nov 2018 23:19:53 +0100 [thread overview]
Message-ID: <87a7mgwp6e.fsf@gnu.org> (raw)
In-Reply-To: <20181105094109.21915-1-dannym@scratchpost.org> (Danny Milosavljevic's message of "Mon, 5 Nov 2018 10:41:09 +0100")
Hello!
Danny Milosavljevic <dannym@scratchpost.org> skribis:
> * gnu/services/monitoring.scm (file-system-monitoring-configuration): New
> variable.
> (file-system-monitoring-entry): New variable.
> (file-system-monitoring-service-type): New variable.
> * gnu/tests/monitoring.scm (%test-file-system-monitoring): New variable.
> * doc/guix.texi (File System Monitoring Service): New subsubsection.
Nice! Should we call it ‘fswatch-monitoring-service’, since there may
be other tools to achieve similar results?
> +@cindex file system monitoring
> +@subsubheading File System Monitoring Service
> +
> +The @code{(gnu services monitoring)} module provides a shepherd service to
s/shepherd/Shepherd/
> +@defvr {Scheme Variable} file-system-monitoring-service-type
> +The service type for @command{fswatch}, which provides the file system
> +monitoring capability.
Perhaps add a @uref to the fswatch home page.
> +@example
> +(service file-system-monitoring-service-type
> + (file-system-monitoring-configuration
> + (monitored-files '("/foo/bar"))
> + (handlers '((lambda args
> + (display "UH OH\n"))))))
It would seem more natural to me for ‘handlers’ to be singular,
‘handler’. Also I’d use a gexp there (though in this particular example
it doesn’t make any difference):
(file-system-monitoring-configuration
(monitored-files '("/foo/bar"))
(handler #~(lambda (file whatever)
(format #t "~a modified!~%" file))))
> + (start #~(let ((handlers
> + (list #$@(map file-system-monitoring-entry-handler
> + monitored-files))))
> + (lambda ()
> + (sleep 1)
> + (for-each (lambda (handler)
> + (handler))
> + handlers)
> + (fork+exec-command
> + `(#$(file-append package "/bin/fswatch")
> + "--one-event"
> + "-l" "1" ; latency: 1 s
> + ; "-d"
> + "--"
> + #$@(if monitored-files
> + (map file-system-monitoring-entry-file-name
> + monitored-files)
> + '("/does_not_exist")))))))
The ‘sleep’ call looks suspicious. :-)
IIUC, the service stops (and is respawned) every time an even occurs, is
that right?
Can’t we instead remove ‘--one-event’ and pass fswatch a script to run?
In that case, we’d pass it something along these lines:
#$(scheme-file "event-handler.scm"
#~(for-each (lambda (handler) …) …))
WDYT?
> +(define file-system-monitoring-service-type
> + (service-type (name 'monitor-file-system)
> + (extensions
> + (list (service-extension shepherd-root-service-type
> + file-system-monitoring-shepherd-services)))
> + (compose concatenate)
> + (extend (lambda (config monitored-entries)
> + (let ((monitored-files
> + (map file-system-monitoring-entry-file-name
> + monitored-entries))
> + (handlers
> + (map file-system-monitoring-entry-handler
> + monitored-entries)))
So here if we changes ‘handlers’ to ‘handler’, we could do:
(apply compose (map file-system-monitoring-entry-handler entries))
Thanks,
Ludo’.
next prev parent reply other threads:[~2018-11-10 22:22 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-11-05 3:18 [bug#33265] [WIP RFC] services: Add file system monitor service Danny Milosavljevic
2018-11-05 3:45 ` [bug#33265] [WIP RFC v2] " Danny Milosavljevic
2018-11-05 3:51 ` [bug#33265] [WIP RFC v3] services: Add file system monitoring service Danny Milosavljevic
2018-11-05 9:16 ` swedebugia
2018-11-05 9:41 ` [bug#33265] [WIP RFC v4] " Danny Milosavljevic
2018-11-10 22:19 ` Ludovic Courtès [this message]
2018-11-11 0:12 ` Danny Milosavljevic
2018-11-11 0:13 ` Danny Milosavljevic
2018-11-11 11:25 ` Ludovic Courtès
2018-11-11 12:30 ` Danny Milosavljevic
2018-11-11 12:50 ` Danny Milosavljevic
2018-11-11 13:22 ` Ludovic Courtès
2018-11-05 9:36 ` [bug#33265] [WIP RFC] services: Add file system monitor service Clément Lassieur
2018-11-11 0:15 ` Danny Milosavljevic
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://guix.gnu.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87a7mgwp6e.fsf@gnu.org \
--to=ludo@gnu.org \
--cc=33265@debbugs.gnu.org \
--cc=dannym@scratchpost.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/guix.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).