package com.cameleer.server.app;

import com.cameleer.server.app.config.AgentRegistryConfig;
import com.cameleer.server.app.config.IngestionConfig;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.scheduling.annotation.EnableScheduling;

import java.util.TimeZone;

/**
 * Main entry point for the Cameleer Server application.
 * <p>
 * Scans {@code com.cameleer.server.app} and {@code com.cameleer.server.core} packages.
 */
@SpringBootApplication(scanBasePackages = {
        "com.cameleer.server.app",
        "com.cameleer.server.core"
})
@EnableAsync
@EnableScheduling
@EnableConfigurationProperties({IngestionConfig.class, AgentRegistryConfig.class})
public class CameleerServerApplication {

    public static void main(String[] args) {
        // Pin JVM default TZ to UTC. The ClickHouse JDBC driver formats
        // java.sql.Timestamp via toString() which uses JVM default TZ; a
        // non-UTC JVM would then send CH timestamps off by the TZ offset.
        // Standard practice for observability servers.
        TimeZone.setDefault(TimeZone.getTimeZone("UTC"));
        SpringApplication.run(CameleerServerApplication.class, args);
    }
}
