diff --git a/acros/management/commands/clearcache.py b/acros/management/commands/clearcache.py new file mode 100644 index 0000000..f052cb6 --- /dev/null +++ b/acros/management/commands/clearcache.py @@ -0,0 +1,7 @@ +from django.core.cache import cache +from django.core.management.base import BaseCommand + + +class Command(BaseCommand): + def handle(self, *args, **kwargs): + cache.clear() diff --git a/acros/templatetags/version.py b/acros/templatetags/version.py index a35fb21..91462b6 100644 --- a/acros/templatetags/version.py +++ b/acros/templatetags/version.py @@ -1,3 +1,4 @@ +from pathlib import Path from subprocess import run from django import template @@ -8,9 +9,10 @@ register = template.Library() @register.simple_tag def commit_id(): + current_dir = Path(__file__).parent commit = cache.get("commit") if not commit: - sp = run(["git", "rev-parse", "--verify", "HEAD"], capture_output=True) + sp = run(["git", "rev-parse", "--verify", "HEAD"], capture_output=True, cwd=current_dir) commit = sp.stdout.decode().strip() cache.set("commit", commit) return commit diff --git a/deploy.sh b/deploy.sh index 2820ea3..10fa9d6 100755 --- a/deploy.sh +++ b/deploy.sh @@ -11,5 +11,6 @@ git pull $manage scss $manage collectstatic --noinput $manage migrate +$manage clearcache sudo systemctl reload acronomy.service