Skip to content
This repository has been archived by the owner on Aug 7, 2018. It is now read-only.

Commit

Permalink
Merge bbf7ecb into 2040b9c
Browse files Browse the repository at this point in the history
  • Loading branch information
lopes05 committed Jun 6, 2018
2 parents 2040b9c + bbf7ecb commit dd637fc
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 2 deletions.
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
FROM radarparlamentar/base:1.0.3

COPY radar_parlamentar/requirements.txt /tmp/requirements.txt

RUN set -ex \
&& pip install -U pip setuptools wheel \
&& pip install -r /tmp/requirements.txt \
Expand Down
1 change: 1 addition & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ services:
- .:/radar
- volume_radar_sockets:/radar/sockets/
- volume_radar_django_static:/radar/radar_parlamentar/static
- ./radar_parlamentar/.pgpass:/root/.pgpass
links:
- postgres
- memcache
Expand Down
1 change: 1 addition & 0 deletions radar_parlamentar/.pgpass
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*:5432:*:radar:radar
9 changes: 7 additions & 2 deletions radar_parlamentar/cron/jobs.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,13 +97,16 @@ def do(self):
logger.info('DbDumperJob foi chamado.')
weekday = date.today().weekday()
# segunda é o zero

if weekday == 0:
logger.info('DbDumperJob fazendo dump do banco.')
dumper = DbDumper()
dumper.dump()
logger.info('Dump realizado.')
else:
logger.info('Hoje não é o dia. DbDumperJob só trabalha às segundas.')

class DbDumper():

# Roteiro:
# OK Verificar que link em dados não tem dump
# criar .pgpass
Expand All @@ -118,8 +121,10 @@ class DbDumper():
DUMP_FILE = "/radar/radar_parlamentar/radar_parlamentar/static/db-dump/radar.sql"

def dump(self):
dump_command = 'pg_dump -h postgres -U radar -d radar -W --inserts -t modelagem_* -f %s' % DbDumper.DUMP_FILE
os.system('chmod 0600 ~/.pgpass') # precisa modificar permissao pra funcionar
dump_command = 'pg_dump -h postgres -U radar -d radar -w --inserts -t modelagem_* -f %s' % DbDumper.DUMP_FILE
os.system(dump_command)

#compress_command = 'bzip2 -9 -f %s' % DbDumper.DUMP_FILE
#os.system(compress_command)
#collectstatic_command = 'python manage.py collectstatic --noinput' # necessário?
Expand Down
1 change: 1 addition & 0 deletions radar_parlamentar/radar_parlamentar/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,7 @@

CRON_CLASSES = [
'cron.jobs.ImportadorJob',
'cron.jobs.DbDumperJob',
]

if os.getenv('RADAR_TEST'):
Expand Down

0 comments on commit dd637fc

Please sign in to comment.