Skip to content
This repository has been archived by the owner on Jan 26, 2021. It is now read-only.

Commit

Permalink
Configure HTTP cache and uploads backup directories
Browse files Browse the repository at this point in the history
  • Loading branch information
ronnix committed Nov 4, 2019
1 parent d9d0501 commit a343995
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
15 changes: 11 additions & 4 deletions admin/tasks/deploy.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,9 @@
from commonmark import commonmark
from fabric.tasks import task

from tools import template_local_file, timestamp
from tools.file import create_directory, sudo_put
from tools import template_local_file
from tools.file import create_directory, is_directory, sudo_put
from tools.git import clone_or_update_repo
from tools.postgres import run_as_postgres
from tools.redis import redis_service_name
from tools.run import sudo_in_dir
from tools.system import cpu_count
Expand Down Expand Up @@ -46,6 +45,8 @@ def deploy_app(
dbpassword="iloveamendements",
notify_rollbar=True,
environment=None,
http_cache_dir="/var/cache/zam/http",
uploads_backup_dir="/var/backups/zam/uploads",
):
print("=== Deploying app ===")

Expand Down Expand Up @@ -92,7 +93,11 @@ def deploy_app(
print("--- Installing Python dependencies ---")
install_requirements(ctx, app_dir=app_dir, venv_dir=venv_dir, user=USER)

create_directory(ctx, "/var/cache/zam/http", owner=USER)
if not is_directory(ctx, http_cache_dir):
create_directory(ctx, http_cache_dir, owner=USER)

if not is_directory(ctx, uploads_backup_dir):
create_directory(ctx, uploads_backup_dir, owner=USER)

print("--- Generating app config file ---")
db_url = f"postgres://{dbuser}:{dbpassword}@{db_host_ip}:5432/{dbname}"
Expand All @@ -113,6 +118,8 @@ def deploy_app(
"gunicorn_timeout": ctx.config["request_timeout"],
"menu_badge_label": menu_badge_label,
"menu_badge_color": menu_badge_color,
"http_cache_dir": http_cache_dir,
"uploads_backup_dir": uploads_backup_dir,
},
)

Expand Down
4 changes: 2 additions & 2 deletions repondeur/production.ini.template
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ zam.auth_secret = $$auth_secret
zam.refresh.amendements = 90
zam.refresh.articles = 90

zam.http_cache_dir = /var/cache/zam/http
zam.uploads_backup_dir = /srv/repondeur/data/uploads
zam.http_cache_dir = $$http_cache_dir
zam.uploads_backup_dir = $$uploads_backup_dir

# Add badge in menu bar to identify environment
zam.menu_badge_label = $$menu_badge_label
Expand Down

0 comments on commit a343995

Please sign in to comment.