musiclink/cmd/musiclink/main.go
Meta-Repo Bot f602c02f80 feat: Prepare for Nix deployment with integration tests and flake
This commit prepares the musiclink bot for production deployment on NixOS.

Changes:
- Refactored service layer to support Dependency Injection for API URLs.
- Added 'internal/bot/bot_integration_test.go' for mock-based integration testing.
- Added 'flake.nix' and 'flake.lock' for reproducible Nix builds.
- Added 'README.md', 'LICENSE', and '.gitignore'.
- Verified build and tests pass locally.
2026-01-16 21:57:13 +00:00

53 lines
1 KiB
Go

package main
import (
"context"
"flag"
"log"
"os"
"os/signal"
"syscall"
"musiclink/internal/bot"
"musiclink/pkg/config"
)
func main() {
configPath := flag.String("config", "config.toml", "path to configuration file")
flag.Parse()
// Load configuration
cfg, err := config.Load(*configPath)
if err != nil {
log.Fatalf("Failed to load config: %v", err)
}
// Create message handler
handler := bot.NewHandler("")
// Create bot
b := bot.New(cfg.Matterbridge, handler.Handle)
// Setup context with cancellation
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
// Handle shutdown signals
sigChan := make(chan os.Signal, 1)
signal.Notify(sigChan, syscall.SIGINT, syscall.SIGTERM)
go func() {
<-sigChan
log.Println("Shutting down...")
cancel()
}()
// Run the bot (connects and reconnects automatically)
log.Println("MusicLink bot starting...")
if err := b.Run(ctx); err != nil && err != context.Canceled {
log.Fatalf("Bot error: %v", err)
}
b.Close()
log.Println("Goodbye!")
}