Initial commit

This commit is contained in:
2023-03-26 16:11:00 +03:00
commit 92469fa3a2
47 changed files with 5610 additions and 0 deletions

42
cmd/service/main.go Normal file
View File

@@ -0,0 +1,42 @@
package main
import (
"context"
"fmt"
"os"
"os/signal"
"sync"
"go.uber.org/zap"
"github.com/derfenix/webarchive/application"
)
func main() {
ctx, cancel := signal.NotifyContext(context.Background(), os.Interrupt, os.Kill)
defer cancel()
cfg, err := application.NewConfig(ctx)
if err != nil {
fmt.Printf("failed to init config: %s", err.Error())
os.Exit(2)
}
app, err := application.NewApplication(cfg)
if err != nil {
fmt.Printf("failed to init application: %s", err.Error())
os.Exit(2)
}
wg := sync.WaitGroup{}
if err := app.Start(ctx, &wg); err != nil {
app.Log().Fatal("failed to start application", zap.Error(err))
}
wg.Wait()
if err := app.Stop(); err != nil {
app.Log().Fatal("failed to graceful stop", zap.Error(err))
}
}