Commit 1fafc86b authored by Nadrieril's avatar Nadrieril

Add agios cron

parent 8b6847c1
......@@ -6,7 +6,7 @@ MAINTAINER Nadrieril "nadrieril@eleves.polytechnique.fr"
#ENV https_proxy http://kuzh.polytechnique.fr:8080
RUN apt-get update && \
apt-get install -y python-pip gunicorn python-dev libmysqlclient-dev python-dateutil
apt-get install -y cron python-pip gunicorn python-dev libmysqlclient-dev python-dateutil
RUN mkdir /app
WORKDIR /app
......@@ -21,8 +21,13 @@ RUN sed -i 's/bars_django\.settings\.dev_local/bars_django.settings.prod/' bars_
# TODO: Temporary
ADD routes.html /app/static/
ADD agios.cron /etc/cron.d/agios
RUN chmod 0744 /etc/cron.d/agios
VOLUME /srv/api
CMD rm -r /srv/api/*; \
cp -R /app/static /srv/api/static; \
python manage.py migrate; \
cron; \
gunicorn bars_django.wsgi -w 4 -b unix:/srv/api/gunicorn.sock --log-level=warning --log-file=-
0 0 * * * root /app/run_agios.sh
# An empty line is required at the end of this file for a valid cron file.
......@@ -17,6 +17,9 @@ class Bar(models.Model):
def __unicode__(self):
return self.id
def apply_agios(self, account):
return 0
class BarSerializer(serializers.ModelSerializer):
class Meta:
......
#!/bin/sh
LOGFILE=/srv/api/cron.log
cd /app
date >> $LOGFILE
python manage.py runscript agios >> $LOGFILE 2>&1
from bars_core.models.account import Account
def run():
sum = 0
for a in Account.objects.select_related('bar'):
sum += a.bar.apply_agios(a)
print "Done (took %f euros)" % sum
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment