Steel/steel.go
Verox007 720f70338f Optimized and beautified concurrency
Credits to Kangaroo rat and zyxkad
2023-12-17 00:43:24 +01:00

40 lines
561 B
Go

package main
import (
"cimeyclust.com/steel/pkg/cmd"
"cimeyclust.com/steel/pkg/net"
"context"
"sync"
)
func main() {
// Channel for stopping the program
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
var wg sync.WaitGroup
// Start the console handler
wg.Add(1)
go func() {
defer wg.Done()
defer cancel()
cmd.Run(ctx)
}()
// Start the network server
wg.Add(1)
go func() {
defer wg.Done()
net.Run(ctx, "localhost:8080")
}()
cmd.Logger.Info("Started")
// Wait for all components to finish
wg.Wait()
}