package main

import (
	"cicv-data-closedloop/aarch64/plugin-compile/package/handler"
	"cicv-data-closedloop/common/config/c_log"
	"cicv-data-closedloop/common/config/c_nacos"
	"cicv-data-closedloop/common/config/c_oss"
	"cicv-data-closedloop/common/handler/h_validate_request_header"
	"cicv-data-closedloop/common/util"
	"net/http"
	"os"
)

const servicePort = 12340
const serviceName = "plugin-compile"

func init() {
	c_log.InitLog("./log/", serviceName)
	c_oss.InitOss(false)
	c_nacos.InitService(true, serviceName, servicePort, map[string]string{
		"开发者":  "孟令鑫",
		"内网IP": "10.14.85.228",
		"外网IP": "36.110.106.142",
	})
}

func main() {
	mux := http.NewServeMux()
	mux.Handle("/compile", h_validate_request_header.HeaderValidationMiddleware(&handler.CompileHandler{}))
	err := http.ListenAndServe(":"+util.ToString(servicePort), mux)
	if err != nil {
		c_log.GlobalLogger.Error("程序崩溃监听端口 " + util.ToString(servicePort) + " 失败。")
		os.Exit(-1)
	}
}
