#!/bin/sh

export APP_JMX_PORT="${JMX_PORT:-11001}"
export APP_JMX_HOSTNAME="${JMX_HOSTNAME:-localhost}"

echo "Запуск Credit Tracker"
exec java \
          -Xmx8G \
          -Xms4G \
          -javaagent:/opt/app/elastic-apm-agent.jar \
          -XX:+UseZGC \
          -Delastic.apm.service_name="${APM_SERVICE_NAME}" \
          -Delastic.apm.server_urls="${APM_SERVER_URLS}" \
          -Delastic.apm.application_packages=ru.nbch \
          -Delastic.apm.environment="${APM_ENVIRONMENT}" \
          -Delastic.apm.service_node_name="${APM_SERVICE_NODE_NAME}" \
          -Delastic.apm.hostname="${APM_SERVICE_NODE_NAME}" \
          -Delastic.apm.service_version="${APM_SERVICE_VERSION}" \
          -Delastic.apm.enable_log_correlation=true \
          -Delastic.apm.stack_trace_limit=0 \
          -Delastic.apm.span_stack_trace_min_duration=-1ms \
          -Dlog4j2.formatMsgNoLookups=true \
          -Dcom.sun.management.jmxremote \
          -Dcom.sun.management.jmxremote.ssl=false \
          -Dcom.sun.management.jmxremote.authenticate=false \
          -Dcom.sun.management.jmxremote.local.only=false \
          -Dcom.sun.management.jmxremote.port="$APP_JMX_PORT" \
          -Dcom.sun.management.jmxremote.rmi.port="$APP_JMX_PORT" \
          -Djava.rmi.server.hostname="$APP_JMX_HOSTNAME" \
          -jar credit-tracker.jar
