Line 0
Link Here
|
0 |
- |
1 |
#!/usr/bin/perl |
|
|
2 |
|
3 |
use Modern::Perl; |
4 |
|
5 |
use C4::Context; |
6 |
use Koha::Caches; |
7 |
|
8 |
use Event; |
9 |
use Linux::Inotify2; |
10 |
|
11 |
my $inotify = Linux::Inotify2->new; |
12 |
|
13 |
Event->io (fd => $inotify->fileno, poll => 'r', cb => sub { $inotify->poll }); |
14 |
|
15 |
our $filename = '/etc/koha/sites/kohadev/koha-conf.xml'; |
16 |
|
17 |
sub cb { |
18 |
my $e = shift; |
19 |
|
20 |
# Flushing the config |
21 |
Koha::Caches->get_instance('config')->flush_all; |
22 |
C4::Context->new; |
23 |
|
24 |
# We need to cancel the watcher and recreate it as the file has been modified (usually delete+creation) |
25 |
$e->w->cancel; |
26 |
|
27 |
$inotify->watch ($filename, IN_MODIFY, \&cb); |
28 |
} |
29 |
|
30 |
$inotify->watch ($filename, IN_MODIFY, \&cb); |
31 |
|
32 |
Event::loop; |