mirror of
https://github.com/renorris/openfsd
synced 2026-03-22 14:35:36 +08:00
Changes:
- Implement bootstrapping library for managing several concurrent internal services
- Refactor concurrency model for connections/logical clients and their associated I/O
- Refactor server context singleton
- Refactor error handling
- Most errors are now gracefully sent to the FSD client directly encoded as an $ER packet,
enhancing visibility and debugging
- Most errors are now rightfully treated as non-fatal
- Refactor package/dependency graph
- Refactor calling conventions/interfaces for many packages
- Refactor database package
- Refactor post office
Features:
- Add VATSIM-esque HTTP/JSON "data feed"
- Add ephemeral in-memory database option
- Add user management REST API
- Add improved web interface
- Add MySQL support (drop SQLite support)
41 lines
771 B
Go
41 lines
771 B
Go
package main
|
|
|
|
import (
|
|
"context"
|
|
"github.com/renorris/openfsd/bootstrap"
|
|
"log"
|
|
"os"
|
|
"os/signal"
|
|
"syscall"
|
|
)
|
|
|
|
func main() {
|
|
b := bootstrap.NewDefaultBootstrap()
|
|
|
|
log.Println("Starting services...")
|
|
|
|
ctx, cancel := context.WithCancel(context.Background())
|
|
if err := b.Start(ctx); err != nil {
|
|
log.Fatalln(err)
|
|
}
|
|
|
|
log.Println("All services started.")
|
|
|
|
// Listen for OS signals
|
|
sigCh := make(chan os.Signal, 1)
|
|
signal.Notify(sigCh, syscall.SIGINT, syscall.SIGTERM)
|
|
|
|
// Wait for either an error or a shutdown signal
|
|
select {
|
|
case sig := <-sigCh:
|
|
log.Printf("received %s", sig)
|
|
cancel()
|
|
case <-b.Done:
|
|
log.Println("FATAL: a service exited early.")
|
|
}
|
|
|
|
log.Println("Waiting for services to stop...")
|
|
<-b.Done
|
|
log.Println("All services stopped.")
|
|
}
|