]> Sergey Matveev's repositories - public-inbox.git/blob - script/public-inbox-watch
watch: introduce watch directive
[public-inbox.git] / script / public-inbox-watch
1 #!/usr/bin/perl -w
2 # Copyright (C) 2016 all contributors <meta@public-inbox.org>
3 # License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt>
4 use strict;
5 use warnings;
6 use PublicInbox::WatchMaildir;
7 use PublicInbox::Config;
8 my $config = PublicInbox::Config->new;
9 my $watch_md = PublicInbox::WatchMaildir->new($config);
10 if ($watch_md) {
11         my $scan = sub { $watch_md->scan };
12         $SIG{USR1} = $scan;
13         $SIG{ALRM} = sub { $SIG{ALRM} = 'DEFAULT'; $scan->() };
14         alarm(1);
15         $watch_md->watch;
16 }