#!/bin/bash
#
# This script is designed to be run inside the container
#
cd /app

# run an idempotent database migration
sudo -E -u deis ./manage.py syncdb --migrate --noinput

# spawn celery worker in the background
sudo -E -u deis celery worker --app=deis --loglevel=INFO --workdir=/app --pidfile=/tmp/celery.pid &

# spawn a gunicorn server in the foreground
sudo -E -u deis ./manage.py run_gunicorn -b 0.0.0.0 -w 8 -t 600 -n deis --log-level debug --pid=/tmp/gunicorn.pid # -k gevent
