#!/usr/bin/env bash
# -*- coding: utf-8 -*-
#
# Copyright (C) 2019 CERN.
# Copyright (C) 2019 Northwestern University.
#
# Invenio App RDM is free software; you can redistribute it and/or modify it
# under the terms of the MIT License; see LICENSE file for more details.

set -e

script_path=$(dirname "$0")

export FLASK_ENV=development
# Start Worker and Server
pipenv run celery worker -A invenio_app.celery -l INFO & pid_celery=$!

pipenv run invenio run \
       --cert "$script_path"/../docker/nginx/test.crt \
       --key "$script_path"/../docker/nginx/test.key & pid_server=$!

trap 'kill $pid_celery $pid_server &>/dev/null' EXIT

wait $pid_celery $pid_server
