#!/bin/sh
set -e

# Start regenerator service in background
node /app/regenerator/server.js &
REGEN_PID=$!

# Start nginx in foreground
nginx -g 'daemon off;' &
NGINX_PID=$!

# Wait for either process to exit; if one dies, kill the other
wait -n $REGEN_PID $NGINX_PID
kill $REGEN_PID $NGINX_PID 2>/dev/null || true
