Files
2026-03-10 14:26:26 +08:00

48 lines
1.0 KiB
Go

package main
import (
"context"
"github.com/joho/godotenv"
"github.com/kelseyhightower/envconfig"
"github.com/langgenius/dify-plugin-daemon/internal/server"
"github.com/langgenius/dify-plugin-daemon/internal/types/app"
"github.com/langgenius/dify-plugin-daemon/pkg/utils/log"
)
func main() {
var config app.Config
// load env
err := godotenv.Load()
if err != nil {
log.Warn("failed to load .env file", "error", err)
}
err = envconfig.Process("", &config)
if err != nil {
log.Panic("error processing environment variables", "error", err)
}
config.SetDefault()
log.Init(config.LogOutputFormat == "json")
defer log.RecoverAndExit()
if err = config.Validate(); err != nil {
log.Panic("invalid configuration", "error", err)
}
// Initialize OpenTelemetry if enabled
if config.EnableOtel {
shutdown, err := server.InitTelemetry(&config)
if err != nil {
log.Panic("failed to init OpenTelemetry", "error", err)
} else {
defer shutdown(context.Background())
}
}
(&server.App{}).Run(&config)
}