mirror of
https://github.com/nestriness/nestri.git
synced 2025-12-12 08:45:38 +02:00
⭐ feat(maitred): Update maitred - hookup to the API (#198)
## Description We are attempting to hookup maitred to the API Maitred duties will be: - [ ] Hookup to the API - [ ] Wait for signal (from the API) to start Steam - [ ] Stop signal to stop the gaming session, clean up Steam... and maybe do the backup ## Summary by CodeRabbit - **New Features** - Introduced Docker-based deployment configurations for both the main and relay applications. - Added new API endpoints enabling real-time machine messaging and enhanced IoT operations. - Expanded database schema and actor types to support improved machine tracking. - **Improvements** - Enhanced real-time communication and relay management with streamlined room handling. - Upgraded dependencies, logging, and error handling for greater stability and performance. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Co-authored-by: DatCaptainHorse <DatCaptainHorse@users.noreply.github.com> Co-authored-by: Kristian Ollikainen <14197772+DatCaptainHorse@users.noreply.github.com>
This commit is contained in:
@@ -1,32 +1,46 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"log"
|
||||
"log/slog"
|
||||
"os"
|
||||
"os/signal"
|
||||
relay "relay/internal"
|
||||
"relay/internal"
|
||||
"relay/internal/common"
|
||||
"syscall"
|
||||
)
|
||||
|
||||
func main() {
|
||||
var err error
|
||||
stopCh := make(chan os.Signal, 1)
|
||||
signal.Notify(stopCh, os.Interrupt, syscall.SIGTERM)
|
||||
// Setup main context and stopper
|
||||
mainCtx, mainStopper := signal.NotifyContext(context.Background(), os.Interrupt, syscall.SIGTERM)
|
||||
|
||||
// Get flags and log them
|
||||
relay.InitFlags()
|
||||
relay.GetFlags().DebugLog()
|
||||
common.InitFlags()
|
||||
common.GetFlags().DebugLog()
|
||||
|
||||
// Init WebRTC API
|
||||
err = relay.InitWebRTCAPI()
|
||||
if err != nil {
|
||||
log.Fatal("Failed to initialize WebRTC API: ", err)
|
||||
logLevel := slog.LevelInfo
|
||||
if common.GetFlags().Verbose {
|
||||
logLevel = slog.LevelDebug
|
||||
}
|
||||
|
||||
// Start our HTTP endpoints
|
||||
relay.InitHTTPEndpoint()
|
||||
// Create the base handler with debug level
|
||||
baseHandler := slog.NewTextHandler(os.Stdout, &slog.HandlerOptions{
|
||||
Level: logLevel,
|
||||
})
|
||||
customHandler := &common.CustomHandler{Handler: baseHandler}
|
||||
logger := slog.New(customHandler)
|
||||
slog.SetDefault(logger)
|
||||
|
||||
// Start relay
|
||||
err := internal.InitRelay(mainCtx, mainStopper, common.GetFlags().MeshPort)
|
||||
if err != nil {
|
||||
slog.Error("Failed to initialize relay", "err", err)
|
||||
mainStopper()
|
||||
return
|
||||
}
|
||||
|
||||
// Wait for exit signal
|
||||
<-stopCh
|
||||
<-mainCtx.Done()
|
||||
log.Println("Shutting down gracefully by signal...")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user