Open magmax opened 8 years ago
The problem is that there could be 1000s of events before the command gets triggered. For example, moving a file into the watched directory causes these events:
EVENT=CREATE WATCHED=/mnt/user/temp/ FILE=b EVENT=OPEN WATCHED=/mnt/user/temp/ FILE=b EVENT=MODIFY WATCHED=/mnt/user/temp/ FILE=b EVENT=ATTRIB WATCHED=/mnt/user/temp/ FILE=b EVENT=ATTRIB WATCHED=/mnt/user/temp/ FILE=b EVENT=CLOSE_WRITE,CLOSE WATCHED=/mnt/user/temp/ FILE=b
Here's an idea: I could create a temp file with all the events since the last run, formatted as above. Then provide an env var like $EVENT_LOG. You could then parse that file. How does that sound?
Performance might be an issue, so we might want to make this optional.
I noticed that docker logs show me exactly the line I want. Something like:
[2022-05-22 00:34:34] movies_monitor: Detected change to directory /dir2/xxxxx
where xxx is the thing I want to access in the COMMAND
instruction.
I looked everywhere within the container for this string or any other log but couldn't find it.
I only found it within the host at a location like /var/lib/docker/containers/<hash>/hash-json.log
but it changes everytime I start the container so I can't even volume-mount that folder and access it within the container because it's a different folder everytime. Classic Chicken and Egg situation.
Is there anyway to have the logs that docker log
outputs avialble in a log file within the container (instead of just on the host)?
It would be great if the command could receive $EVENT, $INFO and $RECORD (and maybe $FILE or something like that) as environment variables, in order to allow different actions or to process exactly what changed.
Another option would be to replace some keywords in the command, but I like more the first option.
Example of command I need::
Thank you!