mirror of
https://github.com/langgenius/dify-plugin-daemon.git
synced 2026-07-22 09:45:27 -04:00
48 lines
1.0 KiB
Go
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)
|
|
}
|