#!/usr/bin/env bash

# {{ ansible_managed }}

{% set discovery_venv_bin = discovery_home + "/venvs/" + discovery_service_name + "/bin" %}
{% if COMMON_ENABLE_NEWRELIC_APP %}
{% set executable = discovery_venv_bin + '/newrelic-admin run-program ' + discovery_venv_bin + '/gunicorn' %}
{% else %}
{% set executable = discovery_venv_bin + '/gunicorn' %}
{% endif %}

{% if COMMON_ENABLE_NEWRELIC_APP %}
export NEW_RELIC_APP_NAME="{{ DISCOVERY_NEWRELIC_APPNAME }}"
export NEW_RELIC_LICENSE_KEY="{{ NEWRELIC_LICENSE_KEY }}"
{% endif -%}

source {{ discovery_home }}/discovery_env
{{ executable }} -c {{ discovery_home }}/discovery_gunicorn.py {{ DISCOVERY_GUNICORN_EXTRA }} course_discovery.wsgi:application
