chore: clean up run.go
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
leo 2023-04-19 21:41:51 +02:00
parent 733f232c49
commit dc0ce9b27a
Signed by: wanderer
SSH Key Fingerprint: SHA256:Dp8+iwKHSlrMEHzE3bJnPng70I7LEsa3IJXRH/U+idQ

13
run.go

@ -51,15 +51,11 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.`
)
var (
addr = flag.String("addr", ":3000", "TCP address:port to listen at")
// compress = flag.Bool("compress", false, "Enable transparent response compression")
addr = flag.String("addr", ":3000", "TCP address:port to listen at")
configFlag = flag.String("config", "config.dhall", "Default path of the config file")
devel = flag.Bool("devel", false, "Run the application in dev mode, connect to a local browser-sync instance for hot-reloading")
// pages = map[string]string{
// "/": "templates/index.tmpl",
// }
version = "dev"
log *slogging.Logger
version = "dev"
log *slogging.Logger
ErrCouldNotInitialiseLogger = errors.New("Could not initialise logger")
)
@ -93,7 +89,9 @@ func run() error {
// for "github.com/xiaoqidun/entps".
connstr := "file:ent?mode=memory&cache=shared&_fk=1"
log.Infof("connecting to db at '%s'", connstr)
db, err := ent.Open("sqlite3", connstr)
if err != nil {
return fmt.Errorf("failed to open a connection to sqlite: %v", err)
@ -148,6 +146,7 @@ func run() error {
<-quit
shutdownTimeout := 10 * time.Second
ctx, cancel := context.WithTimeout(context.Background(), shutdownTimeout)
defer func() {
log.Infof("Interrupt received, gracefully shutting down the server (timeout %s)", shutdownTimeout)