-
Notifications
You must be signed in to change notification settings - Fork 170
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
watch directories #284
Comments
|
Fundamentally, there are two main approaches to do this in Linux land: inotify and fanotify. inotify's issue is that it doesn't recursively monitor directories: you need to implement that yourself. it also takes up memory linearly with the number of monitored files. fanotify is a little better because it can recursively look into directories, but it requires root and doesn't detect renames or delete. i take this from this excellent overview of the linux alternatives there. both have stable python wrappers (inotify and python-fanotify, respectively). but they are both linux-specific, so if we worry about portability at all, we'd probably want to use a wrapper. i found those:
Then there's stuff like gamin and fam that have their own python bindings and of course there are commandline tools like entr and tons more (fswatch, fsnotify, a whole HN! thread about this) that we could connect with without writing our own daemon and leave that in the hands of users + FAQ docs. |
|
I usually use dedicated tools for this, but I agree it could be useful to have a builtin subcommand, possibly with an optional dependency. Another option is to do something more basic, similar to pelican's autorelad (https://github.com/getpelican/pelican/blob/master/pelican/__init__.py#L413). I used watchdog for another project, it seems a reasonable choice. |
|
i'd love to hear more about how you're doing this with "dedicated tools" :) maybe another FAQ? would save me from writing new code maybe... |
|
oh and a |
|
looks like pelican rolled their own file watcher using a busy loop... (https://github.com/getpelican/pelican/blob/master/pelican/utils.py#L727) kind of inefficient which is find for pelican as it's a dev tool, but might not be so good for us in production. but the flag idea is good. |
I meant tools similar to entr, I typically use peat, so nothing fancy.
By production you mean you want to have something that can run continuously on a server ? In this case yes you probably need something based in inotify. |
|
but peat just takes a list of files to watch - does it notice new files as well? and won't it fire as soon as the first file is done transferring and repeatedly fire for every new file? |
|
there's now a FAQ proposed in #285 which could be expanded with this. |
Yes, with the This works quite well: Maybe we can add this to the FAQ for now, then if you or someone else want to add a more powerful |
|
okay, maybe we can start with the FAQ and i can test your answer as an ad-hoc implementation. if i find it unsatisfactory, i'll implement the real thing. ;) |
|
sorry, i'm confused actually; will you or should i add a new section to the FAQ about this here? i'm not sure how you proceed, so i guess I'd let you do it if you don't mind. thanks! |
|
Feel free to add something if you want to do it, help is always much appreciated ;). Otherwise I will add something. |
|
On 2018-01-12 18:41:08, Simon Conseil wrote:
Feel free to add something if you want to do it, help is always much appreciated ;). Otherwise I will add something.
I'd rather let you, if you don't mind. :) You have a better grasp of
this than i have, obviously.
|
|
Okay ;) |
|
Done in 244bc70. |
|
Excellent, thanks for the hint.. it looks like an equivalent command with Unfortunately, it only works for a while - at some point, entr crashes with: ... which seems rather silly. Now, it could be my shell job control messing around: i had suspended and resumed the process and maybe that broke the while loop. But that's not exactly convenient. It would also be tricky to setup an actual system-level service for this, which is my ultimate goal... I'll try to see how to implement an |
|
Update here: for what it's worth, I'm using git-annex and git to manage my galleries now. I dump the high resolution pics in https://gitlab.com/anarcat/git-hooks/blob/master/sigal-git-hook I'll see if I can wrap this up in a docs PR now. |
|
see #351 |
This a separate section to avoid confusion with local builds.
explain how to call sigal from git, se #284
This a separate section to avoid confusion with local builds.
explain how to call sigal from git, se saimn#284
One thing I'm missing in my workflow is a "fire and forget" pattern. Let me explain: what I'm doing right now is I have a remote server with sigal install, where I dump pictures. Right now, I mount the
picturesdirectory through SSH and dump photos there. But then I need to ssh on the remote server and run sigal by hand.I'd like to have some sort of daemon that would sit and watch on a root directory (e.g.
~sigal/picturesin my case) and fire upsigal buildonce changes are detected. This could be done with inotify or similar tools, but this is tricky: we don't want to start the build as soon as a file is created. What we want, actually, is to trigger the build once changes are done and no activity is occuring after a specific timeout.I wonder if you have ever thought of implementing this: I know I could do something with
inotifywaitor similar, but I figured I would look into implementing this in sigal directly as well.Opinions? Ideas? would a PR to that effect be welcome?
The text was updated successfully, but these errors were encountered: