Giter Site home page Giter Site logo

lurker's Introduction

Flint

Build Status

Flint is a microframework build on top of Silex. It brings the full Router, conventions and structure to Silex.

You can read more about in it documentation.

lurker's People

Contributors

dattaya avatar everzet avatar fabpot avatar gquemener avatar henrikbjorn avatar romainneutron avatar stof avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

lurker's Issues

Second argument to track() should be either file or directory resource

create the command in laravel 8

$watcher = new ResourceWatcher;
$watcher->track('folder.watch', 'doc_file/',FilesystemEvent::CREATE);

but when supervisor run got below error

Lurker\Exception\InvalidArgumentException
  Second argument to track() should be either file or directory resource, but got "doc_files/"

"doc_files" is the folder under storage folder

Watching globs with exclusion support

Hi! It would be nice to have ability to add support for tracking globs, like:

$watcher->track('twig.templates', '/path/to/views/*.twig', FilesystemEvent::ALL);

And ability to exlude dirs or files from tracking.

Symfony 3.1

Seems I cannot install lurker because of symfony event 3.1 can you update the requirements in composer.json?

Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - Installation request for henrikbjorn/lurker ^1.1 -> satisfiable by henrikbjorn/lurker[1.1.0].
    - Conclusion: remove symfony/event-dispatcher v3.1.3
    - Conclusion: don't install symfony/event-dispatcher v3.1.3
    - henrikbjorn/lurker 1.1.0 requires symfony/event-dispatcher ~2.2

I see it is changed 5 months ago but never tagged?
https://github.com/flint/Lurker/blob/master/composer.json

ResourceWatcher misses some inotify events

Steps to reproduce:

Setup test directory

cd /some/dir
composer.phar init
composer.phar require henrikbjorn/lurker dev-master
mkdir -p test/foo
touch test/foo/{bar,baz}.txt
vim test.php

Setup test script

// test.php
require_once __DIR__.'/vendor/autoload.php';
use Lurker\Event\FilesystemEvent;
use Lurker\ResourceWatcher;

$watcher = new ResourceWatcher();
$watcher->track('test.foo', __DIR__.'/test/foo');
$watcher->addListener('test.foo', function(FilesystemEvent $event) {
    echo $event->getTypeString() . ' >>> ' . $event->getResource() .PHP_EOL;
});
$watcher->start();

Open two terminals, t1 & t2

t1 $ php test.php
t2 $ echo "something" > test/foo/bar.txt
t1 > modify >>> [..]/test/foo/bar.txt
t2 $ mv test/foo/bar.txt test/
t1 > delete >> [..]/test/foo/bar.txt
t2 $ mv test/bar.txt test/foo/
t1 > ... # nothing !
t2 $ rm test/foo/bar.txt
t1 > ... # nothing !
t2 $ touch test/foo/bar.txt
t1 > create >> [..]/test/foo/bar.txt

Same session with inotifywait

t1 $ inotifywait -rm test/foo
t2 $ echo "something" > test/foo/bar.txt
t1 > test/foo/ MODIFY bar.txt
   > test/foo/ OPEN bar.txt
   > test/foo/ MODIFY bar.txt
   > test/foo/ CLOSE_WRITE,CLOSE bar.txt
t2 $ mv test/foo/bar.txt test/
t1 > test/foo/ MOVED_FROM bar.txt
t2 $ mv test/bar.txt test/foo/
t1 > test/foo/ MOVED_TO bar.txt
t2 $ rm test/foo/bar.txt
t1 > test/foo/ DELETE bar.txt
t2 $ touch test/foo/bar.txt
t1 > test/foo/ CREATE bar.txt
   > test/foo/ OPEN bar.txt
   > test/foo/ ATTRIB bar.txt
   > test/foo/ CLOSE_WRITE,CLOSE bar.txt

Conclusion

It seems Lurker is missing two events here. IN_MOVED_FROM (FilesystemEvent::DELETE) and IN_MOVED_TO (FilesystemEvent::CREATE).
Tested with pecl-inotify 0.1.6

$ php -i | grep inotify -A 2
> inotify
>
> Version => 0.1.1

Windows?

Does this work on Windows? How does it watch files on Windows?

SplFileInfo::getMTime(): stat failed

I'm using Robo and it's file watcher, which uses your lib to track the changes. Sometimes, in random cases, when the file was changed this error comes up:

SplFileInfo::getMTime(): stat failed
\src\Lurker\Resource\DirectoryResource.php:30

I've seen that Symfonys caching suffered from a similar issue, I'm not sure if this will help here as well but maybe it can help fixing the issue. See symfony/symfony@c6e9e06

However, I can't reproduce it as it seems to happen randomly and not very often. I'm using php 5.6 and 5.5 and it happens with both versions. I'm running it on Windows 8. But I've seen that it seems like you're already checking if the file exists.

My guess is that phpstorm, which is sometimes terrible slow, still accesses the file while the change was already detected by the script but phpstorm didn't unlock it at this time.

So maybe an additional check on the lock might solve the issue? See http://stackoverflow.com/questions/9863118/check-if-a-file-is-already-locked-using-flock

Lurker infinite loop on using directory as resource

        $watcher = new \Lurker\ResourceWatcher();
        $watcher->track('provision', __DIR__ . '/.provision');

        $watcher->addListener('provision', function (\Lurker\Event\FilesystemEvent $e) {
            $this->say('----------------------------------------------------------------------');
            $this->say('A change was detected in the provisioning directory...');
            $this->say('Vagrant reprovision might be required based on changes.');
            $this->say('----------------------------------------------------------------------');
        });
...
PHP 224. Lurker\StateChecker\DirectoryStateChecker->createDirectoryChildCheckers() /vagrant/vendor/henrikbjorn/lurker/src/Lurker/StateChecker/DirectoryStateChecker.php:22
PHP 225. Lurker\StateChecker\DirectoryStateChecker->__construct() /vagrant/vendor/henrikbjorn/lurker/src/Lurker/StateChecker/NewDirectoryStateChecker.php:97
PHP 226. Lurker\StateChecker\DirectoryStateChecker->createDirectoryChildCheckers() /vagrant/vendor/henrikbjorn/lurker/src/Lurker/StateChecker/DirectoryStateChecker.php:22
PHP 227. Lurker\StateChecker\DirectoryStateChecker->__construct() /vagrant/vendor/henrikbjorn/lurker/src/Lurker/StateChecker/NewDirectoryStateChecker.php:97
PHP 228. Lurker\StateChecker\DirectoryStateChecker->createDirectoryChildCheckers() /vagrant/vendor/henrikbjorn/lurker/src/Lurker/StateChecker/DirectoryStateChecker.php:22
PHP 229. Lurker\StateChecker\DirectoryStateChecker->__construct() /vagrant/vendor/henrikbjorn/lurker/src/Lurker/StateChecker/NewDirectoryStateChecker.php:97
PHP 230. Lurker\StateChecker\DirectoryStateChecker->createDirectoryChildCheckers() /vagrant/vendor/henrikbjorn/lurker/src/Lurker/StateChecker/DirectoryStateChecker.php:22
PHP 231. Lurker\StateChecker\DirectoryStateChecker->__construct() /vagrant/vendor/henrikbjorn/lurker/src/Lurker/StateChecker/NewDirectoryStateChecker.php:97
PHP 232. Lurker\StateChecker\DirectoryStateChecker->createDirectoryChildCheckers() /vagrant/vendor/henrikbjorn/lurker/src/Lurker/StateChecker/DirectoryStateChecker.php:22
PHP 233. Lurker\StateChecker\DirectoryStateChecker->__construct() /vagrant/vendor/henrikbjorn/lurker/src/Lurker/StateChecker/NewDirectoryStateChecker.php:97
PHP 234. Lurker\StateChecker\DirectoryStateChecker->createDirectoryChildCheckers() /vagrant/vendor/henrikbjorn/lurker/src/Lurker/StateChecker/DirectoryStateChecker.php:22
PHP 235. Lurker\StateChecker\DirectoryStateChecker->__construct() /vagrant/vendor/henrikbjorn/lurker/src/Lurker/StateChecker/NewDirectoryStateChecker.php:97
PHP 236. Lurker\StateChecker\DirectoryStateChecker->createDirectoryChildCheckers() /vagrant/vendor/henrikbjorn/lurker/src/Lurker/StateChecker/DirectoryStateChecker.php:22
PHP 237. Lurker\StateChecker\DirectoryStateChecker->__construct() /vagrant/vendor/henrikbjorn/lurker/src/Lurker/StateChecker/NewDirectoryStateChecker.php:97
PHP 238. Lurker\StateChecker\DirectoryStateChecker->createDirectoryChildCheckers() /vagrant/vendor/henrikbjorn/lurker/src/Lurker/StateChecker/DirectoryStateChecker.php:22
PHP 239. Lurker\StateChecker\DirectoryStateChecker->__construct() /vagrant/vendor/henrikbjorn/lurker/src/Lurker/StateChecker/NewDirectoryStateChecker.php:97
PHP 240. Lurker\StateChecker\DirectoryStateChecker->createDirectoryChildCheckers() /vagrant/vendor/henrikbjorn/lurker/src/Lurker/StateChecker/DirectoryStateChecker.php:22
PHP 241. Lurker\StateChecker\DirectoryStateChecker->__construct() /vagrant/vendor/henrikbjorn/lurker/src/Lurker/StateChecker/NewDirectoryStateChecker.php:97
PHP 242. Lurker\StateChecker\DirectoryStateChecker->createDirectoryChildCheckers() /vagrant/vendor/henrikbjorn/lurker/src/Lurker/StateChecker/DirectoryStateChecker.php:22
PHP 243. Lurker\StateChecker\DirectoryStateChecker->__construct() /vagrant/vendor/henrikbjorn/lurker/src/Lurker/StateChecker/NewDirectoryStateChecker.php:97
PHP 244. Lurker\StateChecker\DirectoryStateChecker->createDirectoryChildCheckers() /vagrant/vendor/henrikbjorn/lurker/src/Lurker/StateChecker/DirectoryStateChecker.php:22
PHP 245. Lurker\StateChecker\DirectoryStateChecker->__construct() /vagrant/vendor/henrikbjorn/lurker/src/Lurker/StateChecker/NewDirectoryStateChecker.php:97
PHP 246. Lurker\StateChecker\DirectoryStateChecker->createDirectoryChildCheckers() /vagrant/vendor/henrikbjorn/lurker/src/Lurker/StateChecker/DirectoryStateChecker.php:22
PHP 247. Lurker\StateChecker\DirectoryStateChecker->__construct() /vagrant/vendor/henrikbjorn/lurker/src/Lurker/StateChecker/NewDirectoryStateChecker.php:97
PHP 248. Lurker\StateChecker\DirectoryStateChecker->createDirectoryChildCheckers() /vagrant/vendor/henrikbjorn/lurker/src/Lurker/StateChecker/DirectoryStateChecker.php:22
PHP 249. Lurker\StateChecker\DirectoryStateChecker->__construct() /vagrant/vendor/henrikbjorn/lurker/src/Lurker/StateChecker/NewDirectoryStateChecker.php:97
PHP 250. Lurker\StateChecker\DirectoryStateChecker->createDirectoryChildCheckers() /vagrant/vendor/henrikbjorn/lurker/src/Lurker/StateChecker/DirectoryStateChecker.php:22
PHP 251. Lurker\StateChecker\DirectoryStateChecker->__construct() /vagrant/vendor/henrikbjorn/lurker/src/Lurker/StateChecker/NewDirectoryStateChecker.php:97
PHP 252. Lurker\StateChecker\DirectoryStateChecker->createDirectoryChildCheckers() /vagrant/vendor/henrikbjorn/lurker/src/Lurker/StateChecker/DirectoryStateChecker.php:22
PHP 253. Lurker\StateChecker\FileStateChecker->__construct() /vagrant/vendor/henrikbjorn/lurker/src/Lurker/StateChecker/NewDirectoryStateChecker.php:99
PHP 254. Lurker\StateChecker\FileStateChecker->__construct() /vagrant/vendor/henrikbjorn/lurker/src/Lurker/StateChecker/FileStateChecker.php:23
PHP 255. Lurker\Resource\FileResource->getModificationTime() /vagrant/vendor/henrikbjorn/lurker/src/Lurker/StateChecker/ResourceStateChecker.php:29
PHP 256. Lurker\Resource\FileResource->exists() /vagrant/vendor/henrikbjorn/lurker/src/Lurker/Resource/FileResource.php:14

Unable to track a non-existent resource - but resource exists

The problem

I have no idea what has changed, but since a few days our task runners (Robo) watcher tasks were not working any more. I've started debugging the issue and figured out that the cause is the is_dir() call when the object is passed.

class DirectoryResource extends BaseDirectoryResource implements ResourceInterface
{
    public function exists()
    {
        return is_dir($this); // Causes the error
                // vs
        return is_dir($this->getResource()); // Works fine
    }
}

I have no idea why this suddenly happens, it happens on php 5.6 which we were using before and it started to happen on Windows and OSX as well.

When I run the tests there is only one failing for me but it seems to be not related to my problem.

There was 1 failure:

1) Lurker\Tests\Tracker\RecursiveIteratorTrackerTest::testTrackSimpleFileChanges
Can not find "C:\Users\Florian\AppData\Local\Temp\sf2_resource_watcher_tests/foo" change event

C:\webstack\htdocs\wa-crm\vendor\henrikbjorn\lurker\tests\Lurker\Tests\Tracker\TrackerTest.php:276
C:\webstack\htdocs\wa-crm\vendor\henrikbjorn\lurker\tests\Lurker\Tests\Tracker\TrackerTest.php:85

←[37;41m←[2KFAILURES!
←[0m←[37;41m←[2KTests: 66, Assertions: 30, Failures: 1, Errors: 18, Skipped: 34.
←[0m←[2K
C:\webstack\htdocs\wa-crm\vendor\henrikbjorn\lurker>

I think it would be better to change the code to use is_dir($this->getResource()) instead of passing the object $this to is_dir(). The documentation states it will accept a string, not an object. I guess the object implements __toString() but for some reason it's not working here.

The (possible) cause

After further investigation I think the cause is probably a change in Symfony\Component\Config\Resource\DirectoryResource:

    public function __toString()
    {
        return md5(serialize(array($this->resource, $this->pattern)));
    }

This won't return the actual path but a hash. Doing print_r((string) $this); shows indeed a hash.

inotify conversion error

The test Lurker\Tests\Tracker\InotifyTrackerTest::testMoveResource fail because the events read from inotify is wrong converted in object.

This is the inotify raw data from the php ext:

array(5) {
  [0]=>
  array(4) {
    ["wd"]=>
    int(1)
    ["mask"]=>
    int(64)
    ["cookie"]=>
    int(538122)
    ["name"]=>
    string(4) "file"
  }
  [1]=>
  array(4) {
    ["wd"]=>
    int(1)
    ["mask"]=>
    int(128)
    ["cookie"]=>
    int(538122)
    ["name"]=>
    string(8) "file_new"
  }
  [2]=>
  array(4) {
    ["wd"]=>
    int(1)
    ["mask"]=>
    int(1073741888)
    ["cookie"]=>
    int(538123)
    ["name"]=>
    string(6) "subdir"
  }
  [3]=>
  array(4) {
    ["wd"]=>
    int(1)
    ["mask"]=>
    int(1073741952)
    ["cookie"]=>
    int(538123)
    ["name"]=>
    string(10) "subdir_new"
  }
  [4]=>
  array(4) {
    ["wd"]=>
    int(2)
    ["mask"]=>
    int(2048)
    ["cookie"]=>
    int(0)
    ["name"]=>
    string(0) ""
  }
}

This is the result from this library:

Path /tmp/sf2_resource_watcher_tests/dir/file => event DELETE
Path /tmp/sf2_resource_watcher_tests/dir/file_new => event CREATE
Path /tmp/sf2_resource_watcher_tests/dir/subdir_new => event CREATE
Path /tmp/sf2_resource_watcher_tests/dir/subdir_new/subfile => event CREATE

The DELETE event for subdir and subdir/subfile have been lost...

Environment:

PHP version:

$ php -v
PHP 7.2.5-1+ubuntu18.04.1+deb.sury.org+1 (cli) (built: May  5 2018 05:00:15) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies
    with Zend OPcache v7.2.5-1+ubuntu18.04.1+deb.sury.org+1, Copyright (c) 1999-2018, by Zend Technologies

PHP ext:

$ php --ri inotify

inotify

Version => 2.0.0

Kernel:

$ uname -srvpio
Linux 4.15.0-22-generic #24-Ubuntu SMP Wed May 16 12:15:17 UTC 2018 x86_64 x86_64 GNU/Linux

Compatibility with Symfony 4

Hi,

I cannot require this package, I'm using Symfony v4.0.4 but it require "symfony/event-dispatcher" : "^2.2|^3.0".

So this raise an error:

Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - Conclusion: remove symfony/symfony v4.0.4
    - Conclusion: don't install symfony/event-dispatcher v3.4.4
    - Installation request for henrikbjorn/lurker ^1.2 -> satisfiable by henrikbjorn/lurker[1.2.0].
    - Conclusion: don't install symfony/symfony v4.0.4
    - henrikbjorn/lurker 1.2.0 requires symfony/event-dispatcher ^2.2|^3.0 -> satisfiable by symfony/event-dispatcher[.....]

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.