Browse Source

En cours de développement

master
losyme 10 months ago
parent
commit
9ab926e277
  1. 8
      go.mod
  2. 16
      go.sum
  3. 3
      internal/api/api.go
  4. 47
      internal/application/application.go

8
go.mod

@ -10,20 +10,20 @@ require (
forge.chapril.org/eckmuhl/router v0.0.0-20211022194545-f5f4f0da45da
forge.chapril.org/losyme/application v0.0.0-20211008200819-b014e639a171
forge.chapril.org/losyme/cmdline v0.0.0-20211010173716-509a4c1f872e
forge.chapril.org/losyme/config v0.0.0-20211020160002-df3ed3bd54a5
forge.chapril.org/losyme/config v0.0.0-20211025142334-51a8a7a73a4f
forge.chapril.org/losyme/errors v0.0.0-20211003204336-ad5510c24b40
forge.chapril.org/losyme/minikit v0.0.0-20211024171508-c788b259f436
forge.chapril.org/losyme/minikit v0.0.0-20211025143143-803c08db301c
forge.chapril.org/losyme/scheduler v0.0.0-20211003204604-f14dada88faf
forge.chapril.org/losyme/util v0.0.0-20211025142031-fd89d32d86fe
forge.chapril.org/losyme/uuid v0.0.0-20211007082235-8d502169e034
)
require (
forge.chapril.org/eckmuhl/server v0.0.0-20211011123843-d223bfacbad9 // indirect
forge.chapril.org/eckmuhl/server v0.0.0-20211025142833-6bfb82ee5b8e // indirect
forge.chapril.org/losyme/buffer v0.0.0-20211003203540-771701f5a518 // indirect
forge.chapril.org/losyme/crypto v0.0.0-20211003213528-e97d4ebea720 // indirect
forge.chapril.org/losyme/kvfmt v0.0.0-20211003204256-34ac32764dae // indirect
forge.chapril.org/losyme/logger v0.0.0-20211020125912-674a399f933c // indirect
forge.chapril.org/losyme/util v0.0.0-20210914170439-20572e6207bf // indirect
github.com/mitchellh/go-homedir v1.1.0 // indirect
github.com/mitchellh/mapstructure v1.4.2 // indirect
github.com/robfig/cron/v3 v3.0.1 // indirect

16
go.sum

@ -8,16 +8,16 @@ forge.chapril.org/eckmuhl/context v0.0.0-20211010163718-0742c5d7087c h1:X5LoqoVw
forge.chapril.org/eckmuhl/context v0.0.0-20211010163718-0742c5d7087c/go.mod h1:mLBQDTayRooyfmrjPQWbIFobAIclOW3ERaikGuQLiUA=
forge.chapril.org/eckmuhl/router v0.0.0-20211022194545-f5f4f0da45da h1:ek3tp+y1BDbesr0FDrtaGLhqoqzZw+YXt14nrh1LQlA=
forge.chapril.org/eckmuhl/router v0.0.0-20211022194545-f5f4f0da45da/go.mod h1:xO6y8Gc6IABsLJaZyl9MmmksISqhPTx0JKjZcQCS3wk=
forge.chapril.org/eckmuhl/server v0.0.0-20211011123843-d223bfacbad9 h1:4MCKcgM4YcTzP4VfV3mxW90wVAjn+XHXgKNy5yfwd24=
forge.chapril.org/eckmuhl/server v0.0.0-20211011123843-d223bfacbad9/go.mod h1:Q/3VgjhCohrpGO+d+cO6762XVpUnkafxoODke0PcFUE=
forge.chapril.org/eckmuhl/server v0.0.0-20211025142833-6bfb82ee5b8e h1:3vqsUmtMp2zb/o4uDZ3yQ47zJgQfkajVwBXsCo1YSUw=
forge.chapril.org/eckmuhl/server v0.0.0-20211025142833-6bfb82ee5b8e/go.mod h1:pCqVQ1FeaeRUymuC/LYA1c+5AY2uqjOZVKZjLysaotk=
forge.chapril.org/losyme/application v0.0.0-20211008200819-b014e639a171 h1:T8MQXGNCs1AsjtIQMYw1gjp0g4H9Frflosm6kkY8e7g=
forge.chapril.org/losyme/application v0.0.0-20211008200819-b014e639a171/go.mod h1:olQo5n5tnBRHq0wcc0lNbymvsXdTuYaCjNfd2d/+01w=
forge.chapril.org/losyme/buffer v0.0.0-20211003203540-771701f5a518 h1:B7wu0DWUwpt0Mw/VTuWQZikhV/VD6kc2iJWbIY+jgEM=
forge.chapril.org/losyme/buffer v0.0.0-20211003203540-771701f5a518/go.mod h1:4Yl585hmF3bWZfuwGF2Ym8ErykJZiF9yawlmK7szIkc=
forge.chapril.org/losyme/cmdline v0.0.0-20211010173716-509a4c1f872e h1:mffUWhhSo++aoX9MkQRn1wsUwz4Y4b7fetRGAVxXBJs=
forge.chapril.org/losyme/cmdline v0.0.0-20211010173716-509a4c1f872e/go.mod h1:eI41RTdJMe1D4lyP/xK20sQKLYHgJSo1mieaOLla8BM=
forge.chapril.org/losyme/config v0.0.0-20211020160002-df3ed3bd54a5 h1:eliEtjVK4iDLflpB+RoB1I08+i6/YiYmrS23vIfYjDY=
forge.chapril.org/losyme/config v0.0.0-20211020160002-df3ed3bd54a5/go.mod h1:Oacy9PnlGYriSyqQW5dgo4vQMBlu5lW77kUssmc491U=
forge.chapril.org/losyme/config v0.0.0-20211025142334-51a8a7a73a4f h1:WkVC71+0mHVg8qpgdTvFU9+fcfgY/vMMmzbaIQtJ4DU=
forge.chapril.org/losyme/config v0.0.0-20211025142334-51a8a7a73a4f/go.mod h1:rEfq3F8ofIUiZ5eMsA0ir9ODUT/tSuudsP1qgh8LMiE=
forge.chapril.org/losyme/crypto v0.0.0-20211003213528-e97d4ebea720 h1:tMwzjPmGvBb5/5Cx0OIPKqT9zMMR6gQn6398rwT0ghc=
forge.chapril.org/losyme/crypto v0.0.0-20211003213528-e97d4ebea720/go.mod h1:zSawWghP8cyqaQNOtKBAWGfAeR93uAyHMqpaXtZJsF8=
forge.chapril.org/losyme/errors v0.0.0-20211003204336-ad5510c24b40 h1:EoVVFHoIsWRlecHmXP4kx3ALchz5DAfNwso3gcl/Jbk=
@ -26,12 +26,12 @@ forge.chapril.org/losyme/kvfmt v0.0.0-20211003204256-34ac32764dae h1:RdYWXKy+OQN
forge.chapril.org/losyme/kvfmt v0.0.0-20211003204256-34ac32764dae/go.mod h1:wnVjwnCO2vFLLZ1EgFuFws1n8XLluufsGsdozGYSA7c=
forge.chapril.org/losyme/logger v0.0.0-20211020125912-674a399f933c h1:AsWWDqFMigGp33sHDqGdJVVACiPYcY1ChSmBN7olBrk=
forge.chapril.org/losyme/logger v0.0.0-20211020125912-674a399f933c/go.mod h1:a3fN8yTjq5S/ramr03hIkutKM/35UsijUgRNKHjjlMU=
forge.chapril.org/losyme/minikit v0.0.0-20211024171508-c788b259f436 h1:IE7c4QC6C3sAQkkurSWBUMj1uo8q3VKubP+5Pj+whSA=
forge.chapril.org/losyme/minikit v0.0.0-20211024171508-c788b259f436/go.mod h1:zWh/ll3ufPkH4n27c1KhA8w20tzIUtXfzL3PfWd/gxM=
forge.chapril.org/losyme/minikit v0.0.0-20211025143143-803c08db301c h1:rd59NgqbvAqoM7iI1wvvMFhvq4DmSWOX6oLtTRWzl4k=
forge.chapril.org/losyme/minikit v0.0.0-20211025143143-803c08db301c/go.mod h1:eWew41AqBgrdGr6XdQgih6IL19Q/TCFE6NPJDESmpDo=
forge.chapril.org/losyme/scheduler v0.0.0-20211003204604-f14dada88faf h1:5OIlwVBTdvjCXh2JHAh5rq8FgSe1lXuuKDFtO/ZRaRM=
forge.chapril.org/losyme/scheduler v0.0.0-20211003204604-f14dada88faf/go.mod h1:VNjFKl0Q2vvLDnR9tdNdTIZDLQNlR+gcIGNf2aIYv3o=
forge.chapril.org/losyme/util v0.0.0-20210914170439-20572e6207bf h1:JZQLbcldf8q/o5OjaYlcNCX/dA1oshGnY6YM2VidAtI=
forge.chapril.org/losyme/util v0.0.0-20210914170439-20572e6207bf/go.mod h1:lKYvkuBOTU3E2HuQZDh4ZSA4u3VcFopQbdPUKaHGHEk=
forge.chapril.org/losyme/util v0.0.0-20211025142031-fd89d32d86fe h1:xjMUKHxtG8jz57JyOxgNLlRaPLJeQvMV9K3HNlhKDB8=
forge.chapril.org/losyme/util v0.0.0-20211025142031-fd89d32d86fe/go.mod h1:lKYvkuBOTU3E2HuQZDh4ZSA4u3VcFopQbdPUKaHGHEk=
forge.chapril.org/losyme/uuid v0.0.0-20211007082235-8d502169e034 h1:4NMOPXxwRiXS7wltj2ZZmMO1nFRMPmG1dXK4Ta4MtiM=
forge.chapril.org/losyme/uuid v0.0.0-20211007082235-8d502169e034/go.mod h1:AgvbvGzTkQkbiM+s9eVhvLUSHbA0V6N+q5oBFI2v0LA=
github.com/mitchellh/go-homedir v1.1.0 h1:lukF9ziXFxDFPkA1vsr5zpc1XuPDn/wFntq5mG+4E0Y=

3
internal/api/api.go

@ -7,6 +7,8 @@
package api
import (
"net/http"
"forge.chapril.org/eckmuhl/context"
"forge.chapril.org/eckmuhl/router"
@ -18,6 +20,7 @@ type api struct {
}
func (api *api) status(c *context.Context) error {
c.Response.WriteHeader(http.StatusOK)
return nil
}

47
internal/application/application.go

@ -7,15 +7,9 @@
package application
import (
"context"
"os"
"os/signal"
"sync"
"syscall"
"time"
"forge.chapril.org/losyme/application"
"forge.chapril.org/losyme/minikit"
"forge.chapril.org/losyme/util"
"forge.chapril.org/dune/dune/internal/api"
"forge.chapril.org/dune/dune/internal/components"
@ -60,36 +54,6 @@ func New(name, version, builtAt string, args []string) *Application {
return app
}
func (app *Application) waitEnd() (*sync.WaitGroup, chan struct{}) {
endCh := make(chan struct{})
group := new(sync.WaitGroup)
group.Add(1)
go func() { //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
defer group.Done()
sigCh := make(chan os.Signal, 1)
defer close(sigCh)
signal.Notify(sigCh, os.Interrupt, syscall.SIGABRT, syscall.SIGQUIT, syscall.SIGTERM)
select {
case <-sigCh:
case <-endCh:
}
<-app.components.Scheduler.Stop().Done()
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
defer cancel()
_ = app.components.Server.Shutdown(ctx) //AFINIR
}()
return group, endCh
}
func (app *Application) run() error {
if err := app.minikit.Build(); err != nil {
return err
@ -111,7 +75,14 @@ func (app *Application) run() error {
app.components.Scheduler.Start()
group, endCh := app.waitEnd()
group, endCh := util.WaitAppEnd(func() {
<-app.components.Scheduler.Stop().Done()
ctx, cancel := util.CtxWithTimeout(10)
defer cancel()
_ = app.components.Server.Shutdown(ctx) //AFINIR
})
err := app.components.Server.ListenAndServe()

Loading…
Cancel
Save