Changeset - 50cfcb768305
[Not reviewed]
0 2 0
Ben Sturmfels (bsturmfels) - 12 months ago 2023-05-06 06:41:30
ben@sturm.com.au
Use cronic to make cron jobs less noisy
2 files changed with 3 insertions and 3 deletions:
0 comments (0 inline, 0 general)
deploy/cron/cron.daily
Show inline comments
 
#!/bin/bash
 

	
 
export DJANGO_SETTINGS_MODULE={{ env.settings }}
 
set -a
 
source {{ env.project_dir }}/env
 

	
 
# PYTHONPATH variable is not preserved by sudo.
 

	
 
# Clear out expired Django sessions.
 
sudo --user={{ env.app_user }} --preserve-env PYTHONPATH={{ env.project_dir }}:$PYTHONPATH {{ env.virtualenv }}/bin/django-admin clearsessions
 
cronic sudo --user={{ env.app_user }} --preserve-env PYTHONPATH={{ env.project_dir }}:$PYTHONPATH {{ env.virtualenv }}/bin/django-admin clearsessions
 

	
 
sudo --user={{ env.app_user }} --preserve-env PYTHONPATH={{ env.project_dir }}:$PYTHONPATH {{ env.virtualenv }}/bin/django-admin expunge_deleted
 
cronic sudo --user={{ env.app_user }} --preserve-env PYTHONPATH={{ env.project_dir }}:$PYTHONPATH {{ env.virtualenv }}/bin/django-admin expunge_deleted
 

	
 

	
 
# Local Variables:
 
# mode: shell-script-mode
 
# End:
fabfile.py
Show inline comments
...
 
@@ -10,25 +10,25 @@ To deploy to production:
 
import os
 

	
 
from fabric import task  # type: ignore
 
from invoke.collection import Collection  # type: ignore
 
from patchwork.files import exists
 
from vps_deploy import django_fabric2 as df2  # type: ignore
 

	
 
hosts = os.environ['FABRIC_HOSTS'].split(',')
 

	
 

	
 
def install_essentials(c):
 
    # ImageMagick (convert) and Inkscape required for generating badges.
 
    c.run('sudo apt-get install -yy git python3-dev python3-venv python3-wheel build-essential python3-cairocffi python3-psycopg2 postgresql uwsgi-emperor uwsgi-plugin-python3 memcached netcat nginx certbot libmemcached-dev xmlsec1 imagemagick inkscape')
 
    c.run('sudo apt-get install -yy git python3-dev python3-venv python3-wheel build-essential python3-cairocffi python3-psycopg2 postgresql uwsgi-emperor uwsgi-plugin-python3 memcached netcat nginx certbot libmemcached-dev xmlsec1 imagemagick inkscape cronic')
 

	
 

	
 
@task(hosts=hosts)
 
def deploy(c):
 
    install_essentials(c)
 
    df2.transfer_files_git(c)
 
    df2.init(c)
 
    if not exists(c, c.env.virtualenv):
 
        c.sudo(f'mkdir -p $(dirname {c.env.virtualenv})')
 
        c.sudo(f'chown {c.user} $(dirname {c.env.virtualenv})')
 
        c.run('{env.python} -m venv --system-site-packages {env.virtualenv}'.format(env=c.env))
 
    with c.cd(c.env.project_dir):
0 comments (0 inline, 0 general)