#!/bin/bash set -e # Initialize if needed (generates identity + channel key + config) if [ ! -f "$FIELDWITNESS_DATA_DIR/config.json" ]; then echo "First run — initializing FieldWitness..." fieldwitness init echo "Initialization complete." fi # Determine HTTPS mode HTTPS_FLAG="" if [ "${FIELDWITNESS_HTTPS_ENABLED:-true}" = "false" ]; then HTTPS_FLAG="--no-https" fi echo "Starting FieldWitness on port ${FIELDWITNESS_PORT:-35811}..." # Run with gunicorn for production exec gunicorn \ --bind "0.0.0.0:${FIELDWITNESS_PORT:-35811}" \ --workers "${FIELDWITNESS_WORKERS:-2}" \ --timeout 180 \ --access-logfile - \ --error-logfile - \ "frontends.web.app:create_app()"