Files
FamilyHUB/backend/src/main.go
T
admin 9d845c8899 Restructured project
- backend moved to backend directory
- added and initialized frontend with vue
- moved infrastructure files to infra directory
2026-04-01 23:16:27 +03:00

47 lines
919 B
Go

package main
import (
"FamilyHub/src/api"
"FamilyHub/src/bot"
"FamilyHub/src/config"
"context"
"log"
)
func main() {
var runnable []Runnable
cfg, err := config.Load()
if err != nil {
log.Fatal(err)
}
ctx := context.Background()
if cfg.RunMode == config.API || cfg.RunMode == config.Standalone {
server := api.NewServer(cfg)
runnable = append(runnable, func(ctx context.Context) error {
log.Println("API started on", cfg.APIPort)
return server.Start()
})
runnable = append(runnable, func(ctx context.Context) error {
<-ctx.Done()
return server.Shutdown(context.Background())
})
}
if cfg.RunMode == config.Bot || cfg.RunMode == config.Standalone {
tgBot, err := bot.NewBot(cfg)
if err != nil {
log.Fatal(err)
}
log.Println("Bot started...")
runnable = append(runnable, func(ctx context.Context) error {
return tgBot.Start(ctx)
})
}
Run(ctx, runnable...)
}