mirror of
https://github.com/derfenix/webarchive.git
synced 2026-03-11 21:35:34 +03:00
Initial commit
This commit is contained in:
42
cmd/service/main.go
Normal file
42
cmd/service/main.go
Normal 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))
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user