A Django app to watch for changes and touch a file.
Project description
Touchwatch
Touchwatch is a small Django app to watch a directory for changes and if any found, touch a file (to trigger a server restart).
Quick start
Add “touchwatch” to your INSTALLED_APPS setting like this:
INSTALLED_APPS = [ ... 'touchwatch', ]Include the polls URLconf in your project urls.py like this:
from touchwatch.views import wsgitime if settings.DEBUG: urlpatterns += path('wt/', wsgitime, name='wsgitime'),Include the template at the bottom of your base.html file
{% include “touchwatch/js.html” %}
4.. Set the path of the file you want to touch in your settings file OR set the command you want to be run
TOUCHWATCH_PATH = “%s/uwsgi.ini” % APP_DIR
TOUCHWATCH_COMMAND = “ps -ef | grep ‘gunicorn’ | grep -v grep | awk ‘{print $2}’ | xargs -r kill -HUP 2> /dev/null”
5.. Set the path of the folder you want to watch in your settings file
TOUCHWATCH_FOLDER = APP_DIR
How it works
From the commandline run the management command ‘touchwatch’:
python manage.py touchwatch
This will then sit and watch for changes to the file defined in TOUCHWATCH_FOLDER, when changes are seen then the file defined in TOUCHWATCH_PATH will be touched. A small piece of JS runs on all pages on the browser which looks for a change to the touched time of the defined file. When the time changes, the JS flashes the background colour and refreshes the page.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
File details
Details for the file touchwatch-0.2.tar.gz.
File metadata
- Download URL: touchwatch-0.2.tar.gz
- Upload date:
- Size: 6.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.8.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
411a048b0b55828526907ae480219db602700fdfedb25a764f1dc94ac8cecaa9
|
|
| MD5 |
8cb015f21f4e7e8ff1dcee68997457a0
|
|
| BLAKE2b-256 |
17300d4ffd2fad600bfca42ad16a9d02efb80ee0b2c51617fd2d77f9e3084ae7
|