diff --git a/ansible/tasks/akanda.yml b/ansible/tasks/akanda.yml index 7f6404b..085ae9b 100644 --- a/ansible/tasks/akanda.yml +++ b/ansible/tasks/akanda.yml @@ -5,6 +5,7 @@ with_items: - python-pip - python-dev + - logrotate - name: copy akanda-appliance code synchronize: src={{ playbook_dir }}/.. dest=/tmp/akanda-appliance @@ -18,6 +19,12 @@ - name: install akanda-appliance command: python setup.py install chdir=/tmp/akanda-appliance +- name: install akanda gunicorn logging directory + file: path=/var/log/akanda state=directory + +- name: install akanda logrotate config + template: src=logrotate.j2 dest=/etc/logrotate.d/akanda + - name: install gunicorn config file template: src=gunicorn.j2 dest=/etc/akanda_gunicorn_config diff --git a/ansible/templates/gunicorn.j2 b/ansible/templates/gunicorn.j2 index 6fda01e..6098faa 100644 --- a/ansible/templates/gunicorn.j2 +++ b/ansible/templates/gunicorn.j2 @@ -8,4 +8,5 @@ worker_class ="sync" debug = False daemon = True pidfile = "/var/run/gunicorn.pid" -errorfile = "/tmp/gunicorn.log" +errorlog = "/var/log/akanda/gunicorn_error.log" +accesslog = "/var/log/akanda/gunicorn_access.log" diff --git a/ansible/templates/logrotate.j2 b/ansible/templates/logrotate.j2 new file mode 100644 index 0000000..74053cf --- /dev/null +++ b/ansible/templates/logrotate.j2 @@ -0,0 +1,10 @@ +/var/log/akanda/*.log { + weekly + rotate 7 + compress + missingok + create 644 root root + postrotate + kill -USR1 `cat /var/run/gunicorn.pid` + endscript +}