Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CPAN install breaks in Mac::FSEvents #607

Closed
c-alpha opened this issue May 13, 2022 · 1 comment
Closed

CPAN install breaks in Mac::FSEvents #607

c-alpha opened this issue May 13, 2022 · 1 comment

Comments

@c-alpha
Copy link

c-alpha commented May 13, 2022

cpanm Statocles breaks when building Mac-FSEvents-0.14.

Peeking into the code of that module, it seems it supports macOS only up to, and including major version 10. I.e. macOS 11 (Big Sur) and 12 (Monetrey) are not supported.

Can it be replaced with something that is still maintained? Is it needed at all (looking at #189)?

@c-alpha
Copy link
Author

c-alpha commented Jun 4, 2022

I looked into /lib/Statocles/Command/daemon.pm, where Mac::FSEvents is used. Without any experience with Mojolicious on my part (cough), I think the relevant section in startup() could potentially be replaced with code along the lines of this little test script:

#!/usr/bin/env -S perl

use Mojo::IOLoop;
use File::ChangeNotify;

my $latency = 1.0;        # in seconds
my $ioloop = Mojo::IOLoop->singleton;
my $watches = [ '.' ];    # list more paths as needed

my $watcher =
  File::ChangeNotify->instantiate_watcher
  ( directories     => $watches,
    sleep_interval  => $latency,
    # follow_symlinks => 1,    # By default, symlinks are ignored. Set this to true to follow them.
  );

$ioloop->reactor->recurring ( $latency => sub {
                                my $rebuild = 0;
                                for my $event ( $watcher->new_events ) {
                                  print "Path '" . $event->path . "' changed...\n";
                                  $rebuild = 1;
                                }
                                if ($rebuild) {
                                  print "Rebuilding site\n";
                                }
                              } );

$ioloop->reactor->start;

File::ChangeNotify IMO has two advantages: it provides the feature cross-platform (i.e. no longer restricted to Mac), and it can watch several paths at once (i.e. code in startup() could perhaps be simplified).

@c-alpha c-alpha closed this as completed Jan 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant