Skip to content

Instantly share code, notes, and snippets.

@jnthn

jnthn/x.p6 Secret

Last active June 27, 2017 14:15
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save jnthn/32c3359202ec5c1a869b00e372fc2a75 to your computer and use it in GitHub Desktop.
sub MAIN (
Str :$root = '/home/' ~ %*ENV<USER> ~ '/sparky-root',
Int :$timeout = 360,
Str :$reports-root = '/home/' ~ %*ENV<USER> ~ '/sparky-reports',
)
{
react {
sub run-project($dir, $project) {
my $cmd = "sparrowdo --sparrowfile=$dir/sparrowfile > $reports-root/$project.txt 2>&1";
whenever Proc::Async.new('/bin/sh', '-c', $cmd).start {
run-project($dir, $project);
}
}
sub add-dirs() {
state %seen;
for dir($root) -> $dir {
next if %seen{$dir}++;
next unless "$dir/sparrowfile".IO ~~ :f;
run-project($dir, $dir.basename);
}
}
whenever IO::Notification.watch-path($root) {
add-dirs();
}
add-dirs();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment