mirror of
https://github.com/derfenix/webarchive.git
synced 2026-03-11 12:41:54 +03:00
43 lines
772 B
Go
43 lines
772 B
Go
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))
|
|
}
|
|
}
|