# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements.  See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership.  The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License.  You may obtain a copy of the License at
#
#   http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied.  See the License for the
# specific language governing permissions and limitations
# under the License.

[supervisord]
nodaemon=true
logfile=/var/log/supervisor/supervisord.log
pidfile=/var/run/supervisord.pid
user=root

[program:postgresql]
command=/usr/lib/postgresql/14/bin/postgres -D /var/lib/postgresql/data -c config_file=/etc/postgresql/14/main/postgresql.conf
user=postgres
autostart=true
autorestart=true
stderr_logfile=/var/log/supervisor/postgresql.err.log
stdout_logfile=/var/log/supervisor/postgresql.out.log
environment=PGDATA="/var/lib/postgresql/data"
priority=100

# ResilientDB runs in a separate container (same network)
# This allows us to use the official ResilientDB image without rebuilding

[program:graphq-llm-backend]
command=/bin/bash -c "cd /app/graphq-llm && npm run http-api"
autostart=true
autorestart=true
stderr_logfile=/var/log/supervisor/graphq-llm.err.log
stdout_logfile=/var/log/supervisor/graphq-llm.out.log
environment=RESILIENTDB_GRAPHQL_URL="http://localhost:5001/graphql",DATABASE_URL="postgres://nexus:nexus@localhost:5432/nexus",NODE_ENV="production"
priority=300
startsecs=60

[unix_http_server]
file=/var/run/supervisor.sock

[supervisorctl]
serverurl=unix:///var/run/supervisor.sock

[rpcinterface:supervisor]
supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface

