chore: clean up run.go
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
733f232c49
commit
dc0ce9b27a
7
run.go
7
run.go
@ -52,12 +52,8 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.`
|
|||||||
|
|
||||||
var (
|
var (
|
||||||
addr = flag.String("addr", ":3000", "TCP address:port to listen at")
|
addr = flag.String("addr", ":3000", "TCP address:port to listen at")
|
||||||
// compress = flag.Bool("compress", false, "Enable transparent response compression")
|
|
||||||
configFlag = flag.String("config", "config.dhall", "Default path of the config file")
|
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")
|
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"
|
version = "dev"
|
||||||
log *slogging.Logger
|
log *slogging.Logger
|
||||||
|
|
||||||
@ -93,7 +89,9 @@ func run() error {
|
|||||||
|
|
||||||
// for "github.com/xiaoqidun/entps".
|
// for "github.com/xiaoqidun/entps".
|
||||||
connstr := "file:ent?mode=memory&cache=shared&_fk=1"
|
connstr := "file:ent?mode=memory&cache=shared&_fk=1"
|
||||||
|
|
||||||
log.Infof("connecting to db at '%s'", connstr)
|
log.Infof("connecting to db at '%s'", connstr)
|
||||||
|
|
||||||
db, err := ent.Open("sqlite3", connstr)
|
db, err := ent.Open("sqlite3", connstr)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("failed to open a connection to sqlite: %v", err)
|
return fmt.Errorf("failed to open a connection to sqlite: %v", err)
|
||||||
@ -148,6 +146,7 @@ func run() error {
|
|||||||
<-quit
|
<-quit
|
||||||
|
|
||||||
shutdownTimeout := 10 * time.Second
|
shutdownTimeout := 10 * time.Second
|
||||||
|
|
||||||
ctx, cancel := context.WithTimeout(context.Background(), shutdownTimeout)
|
ctx, cancel := context.WithTimeout(context.Background(), shutdownTimeout)
|
||||||
defer func() {
|
defer func() {
|
||||||
log.Infof("Interrupt received, gracefully shutting down the server (timeout %s)", shutdownTimeout)
|
log.Infof("Interrupt received, gracefully shutting down the server (timeout %s)", shutdownTimeout)
|
||||||
|
Loading…
Reference in New Issue
Block a user