package main

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

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

func init() {
	c_log.InitLog("/root/cicv-data-closedloop/deploy/log/", serviceName)
	config.InitOss(false)
	config.InitOss2(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{}))
	mux.Handle("/pji_compile", h_validate_request_header.HeaderValidationMiddleware(&handler.PjiCompileHandler{}))
	err := http.ListenAndServe(":"+util.ToString(servicePort), mux)
	if err != nil {
		c_log.GlobalLogger.Error("程序崩溃监听端口 " + util.ToString(servicePort) + " 失败。")
		os.Exit(-1)
	}
}
