Skip to content

Commit

Permalink
cron for production
Browse files Browse the repository at this point in the history
  • Loading branch information
noisy committed Mar 4, 2018
1 parent 0dba38c commit ea3d856
Show file tree
Hide file tree
Showing 11 changed files with 37 additions and 41 deletions.
2 changes: 0 additions & 2 deletions chroniker_crontab

This file was deleted.

11 changes: 8 additions & 3 deletions compose/django/Dockerfile
Expand Up @@ -19,7 +19,7 @@ RUN pip install -r /requirements.txt \
&& useradd -m -r -g django django

RUN apt-get install -y ruby-dev rubygems
RUN apt-get install -y cron
RUN apt-get install -y cron rsyslog

RUN gem install sass

Expand All @@ -35,8 +35,13 @@ RUN sed -i 's/\r//' /start.sh \
&& chmod +x /start.sh \
&& chown django /start.sh

ADD chroniker_crontab /etc/cron.d/chroniker-cron
RUN chmod 0644 /etc/cron.d/chroniker-cron
COPY ./compose/django/configure_and_run_cron.sh /configure_and_run_cron.sh
RUN chmod +x /configure_and_run_cron.sh \
&& chown django /configure_and_run_cron.sh

COPY ./compose/django/cron.sh /cron.sh
RUN chmod +x /cron.sh \
&& chown django /cron.sh

WORKDIR /app

Expand Down
8 changes: 0 additions & 8 deletions compose/django/Dockerfile-dev
Expand Up @@ -17,8 +17,6 @@ RUN pip install steem
RUN pip install -r /requirements.txt

RUN apt-get install -y ruby-dev rubygems
RUN apt-get install -y cron

RUN gem install sass

COPY ./compose/django/entrypoint.sh /entrypoint.sh
Expand All @@ -29,12 +27,6 @@ COPY ./compose/django/start-dev.sh /start-dev.sh
RUN sed -i 's/\r//' /start-dev.sh
RUN chmod +x /start-dev.sh

COPY ./compose/django/start-cron-dev.sh /start-cron-dev.sh
RUN chmod +x /start-cron-dev.sh

COPY ./compose/django/cron.sh /cron.sh
RUN chmod +x /cron.sh

WORKDIR /app

ENTRYPOINT ["/entrypoint.sh"]
10 changes: 10 additions & 0 deletions compose/django/configure_and_run_cron.sh
@@ -0,0 +1,10 @@
#!/bin/bash

dotenv list > /tmp/env
sed -i 's/^/export /' /tmp/env

echo "* * * * * django /cron.sh" > /etc/cron.d/django

rsyslogd
cron
tail -f /var/log/syslog
9 changes: 4 additions & 5 deletions compose/django/cron.sh
@@ -1,6 +1,5 @@
set -a
. /app/.env.local
set +a
#!/bin/bash

/usr/local/bin/chroniker -p /app/ -s settings.test
#python /app/manage.py cron
source /etc/profile
source /tmp/env
/entrypoint.sh python /app/manage.py cron >> /app/cron-logs 2>&1
3 changes: 0 additions & 3 deletions compose/django/start-cron-dev.sh

This file was deleted.

1 change: 0 additions & 1 deletion compose/django/start.sh
@@ -1,7 +1,6 @@
#!/bin/sh
./bin/apply_theme.sh
sass --update --force static/scss:static/css
cron -f&
python manage.py migrate
python /app/manage.py collectstatic --noinput
/usr/local/bin/uwsgi --http :5000 \
Expand Down
19 changes: 0 additions & 19 deletions dev.yml
Expand Up @@ -30,22 +30,3 @@ services:
- postgres
env_file:
- .env.local

django-chroniker:
build:
context: .
dockerfile: ./compose/django/Dockerfile-dev
command: /start-cron-dev.sh
depends_on:
- postgres
- redis
- django
volumes:
- .:/app
links:
- postgres
env_file:
- .env.local

redis:
build: ./compose/redis
13 changes: 13 additions & 0 deletions docker-compose.yml
Expand Up @@ -46,5 +46,18 @@ services:
command: /start.sh
env_file: .env

django-chroniker:
build:
context: .
dockerfile: ./compose/django/Dockerfile
command: /configure_and_run_cron.sh
depends_on:
- postgres
- redis
links:
- postgres
env_file:
- .env

redis:
build: ./compose/redis
1 change: 1 addition & 0 deletions fabfile.py
Expand Up @@ -123,6 +123,7 @@ def deploy(branch="master"):
time.sleep(10)

_build_and_restart("django-b")
_build_and_restart("django-chroniker")
docker_compose("run django-a python manage.py searchv2_build")


Expand Down
1 change: 1 addition & 0 deletions requirements.txt
Expand Up @@ -35,6 +35,7 @@ whitenoise==3.2.2
Pillow==4.2.1
rocketchat-API==0.6.3
markdown==2.6.11
python-dotenv==0.8.0

# Redis support
django-redis==4.6.0
Expand Down

0 comments on commit ea3d856

Please sign in to comment.