Skip to content

Commit 8edb9c0

Browse files
authored
Merge pull request #25 from onaio/add-logrotate
Add Log Rotation
2 parents 645ed07 + cb0f490 commit 8edb9c0

File tree

4 files changed

+20
-3
lines changed

4 files changed

+20
-3
lines changed

tasks/configure.yml

+9-1
Original file line numberDiff line numberDiff line change
@@ -49,4 +49,12 @@
4949
owner: "{{ django_system_user }}"
5050
group: "{{ django_system_group }}"
5151
notify:
52-
- restart_service
52+
- restart_service
53+
54+
- name: customize logrotate rules
55+
template:
56+
src: etc/logrotate.d/django.j2
57+
dest: "/etc/logrotate.d/{{ django_service_name }}"
58+
owner: root
59+
group: root
60+
mode: 0644

templates/etc/default/celerybeat.j2

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ CELERYBEAT_GROUP="{{ django_system_group }}"
1818
PROJET_ENV="{{ django_env_name }}"
1919
C_FORCE_ROOT=1
2020
CELERYBEAT_LOG_LEVEL="{{ django_celerybeat_log_level }}"
21-
CELERYBEAT_LOG_FILE="/var/log/{{ django_system_user }}/celerybeat.log"
21+
CELERYBEAT_LOG_FILE="{{ django_log_path }}celerybeat.log"
2222
CELERY_CREATE_DIRS=1
2323
CELERYBEAT_SCHEDULE="/var/run/{{ django_system_user }}/celerybeat-schedule"
2424
CELERYBEAT_STATE_DIR="/var/run/{{ django_system_user }}/celerybeat"

templates/etc/default/celeryd.j2

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ CELERY_APP="{{ django_celery_app }}"
2121
#CELERY_CONFIG_MODULE="celeryconfig"
2222

2323
# %n will be replaced with the nodename.
24-
CELERYD_LOG_FILE="/var/log/{{ django_system_user }}/celery-%n.log"
24+
CELERYD_LOG_FILE="{{ django_log_path }}/celery-%n.log"
2525
{% if django_celeryd_pid_file %}
2626
CELERYD_PID_FILE="{{ django_celeryd_pid_file }}"
2727
{% else %}

templates/etc/logrotate.d/django.j2

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
"{{ django_log_path }}/*.log" "{{ django_wsgi_logto }}" {
2+
copytruncate
3+
daily
4+
rotate 52
5+
compress
6+
delaycompress
7+
missingok
8+
notifempty
9+
}

0 commit comments

Comments
 (0)