A Python-based system for monitoring file changes and acting upon specific events. Utilizing a pub-sub, event-sourcing architecture, this project aims to offer a simple but extensible solution for various file event-driven requirements.
The current Python-based implementation likely will not be fast or efficient enough to monitor large portions of a production system. The main goal of this particular implementation is to be as simple as possible while still using an extensible scaffolding. If this works reasonably well, it will likely be rewritten, perhaps in a different language, likely with a different inotify library, or a library using another language and an FFI will be provided with the necessary facilities to ensure this is performant-enough to track changes to production systems.
- Event-driven architecture: Quickly act upon changes with custom handlers.
- Multi-threaded: Handle multiple events concurrently without blocking.
- Configurable: Adjust the behavior of the system based on requirements.
- Integrated with
inotify-simple
for efficient file change notifications.
- Python 3.10.12
- poetry (for dependency management)
- Clone the repository:
git clone https://github.com/alexanderkjackson-protonmail-com/etcWatch
- Navigate to the project folder:
cd etcWatch
- Install dependencies using poetry:
poetry install
Simply run the main python file:
poetry run python etcWatch.py
The system's behavior can be configured by modifying the config
dictionary in the main python file. You can select different event processors and persisters based on your requirements.
- Implement a new class that inherits from the
EventProcessor
interface. - Override the
process_event
method with your custom logic. - Adjust the configuration to use your new processor.
Use the PubSub
class to subscribe to specific event types. You can create custom subscribers by implementing the Subscriber
interface and overriding the handle_event
method.
This project utilizes the inotify-simple
library to efficiently detect file changes.
GNU GPL v3
Feel free to open issues, suggest improvements, or submit pull requests. When submitting pull requests, your code doesn't have to be good or tested. I'll take anything!
Partway through the project, an issue similar or identical to the following was encountered: python-poetry/poetry#1917
Quickfix: export PYTHON_KEYRING_BACKEND=keyring.backends.null.Keyring More permanent fix, which I suspect will cause issues if using a private repo: python3 -m keyring --disable
I don't anticipate using a private repo in this project, so the above will likely have no drawbacks.