#!/bin/bash -e
# Startup script to run the ASR Engine as a web service over HTTP (i.e. without SSL encryption).

echo "==== Not configuring SSL certificate..."
echo "WARNING: these web services are configured without transport encryption!" >&2
echo "See https-engine for an alternate script that configures Apache with SSL." >&2
echo "Please ensure that TCP connections are restricted to a trusted network." >&2
echo "Or pass incoming HTTP requests through a secure proxy or load balancer." >&2
echo

# Enable an Apache site configuration that will:
# - serve static documentation and audio files;
# - run the REST API (process-internal via Flask/WSGI);
# - proxy the WebSocket server, running at ws://localhost:9980;
# - listen on TCP port 80.
sudo a2ensite mod9-asr > /dev/null  # Hide confusing/misleading messages.

# Start web services in background, run ASR Engine in foreground with passed arguments.
exec www-engine $@
