Initial commit
This commit contains skeleton of the application with uber/fx DI library.
This commit is contained in:
commit
0507cdb3d1
6 changed files with 115 additions and 0 deletions
26
modules/grace/graceful.go
Normal file
26
modules/grace/graceful.go
Normal file
|
@ -0,0 +1,26 @@
|
|||
package grace
|
||||
|
||||
import (
|
||||
"context"
|
||||
"log"
|
||||
"os"
|
||||
"os/signal"
|
||||
"syscall"
|
||||
)
|
||||
|
||||
func NewGracefulContext() context.Context {
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
|
||||
go func() {
|
||||
ch := make(chan os.Signal, 1)
|
||||
signal.Notify(ch, syscall.SIGINT, syscall.SIGTERM)
|
||||
select {
|
||||
case <-ch:
|
||||
log.Print("ctx: caught interrupt signal")
|
||||
cancel()
|
||||
case <-ctx.Done():
|
||||
}
|
||||
}()
|
||||
|
||||
return ctx
|
||||
}
|
20
modules/settings/settings.go
Normal file
20
modules/settings/settings.go
Normal file
|
@ -0,0 +1,20 @@
|
|||
package settings
|
||||
|
||||
const (
|
||||
version = "3.0.0"
|
||||
discordTokenPath = "./tokens/.discordtoken"
|
||||
)
|
||||
|
||||
type (
|
||||
Settings struct {
|
||||
Version string
|
||||
DiscordTokenPath string
|
||||
}
|
||||
)
|
||||
|
||||
func NewSettings() Settings {
|
||||
return Settings{
|
||||
Version: version,
|
||||
DiscordTokenPath: discordTokenPath,
|
||||
}
|
||||
}
|
0
modules/tokens/.gitkeep
Normal file
0
modules/tokens/.gitkeep
Normal file
Loading…
Add table
Add a link
Reference in a new issue