Open ghost opened 4 years ago
Hi guys,
Hope you are doing well !
I have this error while running the demo.
WARNING: AssetFS is used before overwrite it! goroutine 1 [running, locked to thread]: runtime/debug.Stack(0x2e, 0x0, 0x0) /usr/local/Cellar/go/1.14/libexec/src/runtime/debug/stack.go:24 +0x9d runtime/debug.PrintStack() /usr/local/Cellar/go/1.14/libexec/src/runtime/debug/stack.go:16 +0x22 github.com/qorpress/qorpress-example/vendor/github.com/qorpress/assetfs.SetAssetFS(0x771e258, 0x57aa420) /Users/lucmichalski/go/src/github.com/qorpress/qorpress-example/vendor/github.com/qorpress/assetfs/assetfs.go:33 +0xc5 github.com/qorpress/qorpress-example/pkg/config/bindatafs.init.0() /Users/lucmichalski/go/src/github.com/qorpress/qorpress-example/pkg/config/bindatafs/bindatafs.go:26 +0x5d
package main import ( "context" "flag" "fmt" "net/http" "os" "path/filepath" "github.com/go-chi/chi" "github.com/go-chi/chi/middleware" "github.com/qorpress/admin" "github.com/qorpress/publish2" "github.com/qorpress/qor" "github.com/qorpress/qor/utils" "github.com/qorpress/qorpress-example/pkg/app/account" adminapp "github.com/qorpress/qorpress-example/pkg/app/admin" "github.com/qorpress/qorpress-example/pkg/app/api" "github.com/qorpress/qorpress-example/pkg/app/home" "github.com/qorpress/qorpress-example/pkg/app/pages" "github.com/qorpress/qorpress-example/pkg/app/posts" "github.com/qorpress/qorpress-example/pkg/app/static" "github.com/qorpress/qorpress-example/pkg/config" "github.com/qorpress/qorpress-example/pkg/config/application" "github.com/qorpress/qorpress-example/pkg/config/auth" "github.com/qorpress/qorpress-example/pkg/config/bindatafs" "github.com/qorpress/qorpress-example/pkg/config/db" _ "github.com/qorpress/qorpress-example/pkg/config/db/migrations" "github.com/qorpress/qorpress-example/pkg/utils/funcmapmaker" ) func main() { cmdLine := flag.NewFlagSet(os.Args[0], flag.ContinueOnError) compileTemplate := cmdLine.Bool("compile-templates", false, "Compile Templates") cmdLine.Parse(os.Args[1:]) var ( Router = chi.NewRouter() Admin = admin.New(&admin.AdminConfig{ SiteName: "QORPRESS DEMO", Auth: auth.AdminAuth{}, DB: db.DB.Set(publish2.VisibleMode, publish2.ModeOff).Set(publish2.ScheduleMode, publish2.ModeOff), }) Application = application.New(&application.Config{ Router: Router, Admin: Admin, DB: db.DB, }) ) funcmapmaker.AddFuncMapMaker(auth.Auth.Config.Render) Router.Use(func(handler http.Handler) http.Handler { return http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) { // for demo, don't use this for your production site w.Header().Add("Access-Control-Allow-Origin", "*") handler.ServeHTTP(w, req) }) }) Router.Use(func(handler http.Handler) http.Handler { return http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) { req.Header.Del("Authorization") handler.ServeHTTP(w, req) }) }) Router.Use(middleware.RealIP) Router.Use(middleware.Logger) Router.Use(middleware.Recoverer) Router.Use(func(next http.Handler) http.Handler { return http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) { var ( tx = db.DB qorContext = &qor.Context{Request: req, Writer: w} ) if locale := utils.GetLocale(qorContext); locale != "" { tx = tx.Set("l10n:locale", locale) } ctx := context.WithValue(req.Context(), utils.ContextDBName, publish2.PreviewByDB(tx, qorContext)) next.ServeHTTP(w, req.WithContext(ctx)) }) }) Application.Use(api.New(&api.Config{})) Application.Use(adminapp.New(&adminapp.Config{})) Application.Use(home.New(&home.Config{})) Application.Use(posts.New(&posts.Config{})) Application.Use(account.New(&account.Config{})) Application.Use(pages.New(&pages.Config{})) Application.Use(static.New(&static.Config{ Prefixs: []string{"/system"}, Handler: utils.FileServer(http.Dir(filepath.Join(config.Root, "public"))), })) Application.Use(static.New(&static.Config{ Prefixs: []string{"javascripts", "stylesheets", "images", "dist", "fonts", "vendors", "favicon.ico"}, Handler: bindatafs.AssetFS.FileServer(http.Dir(filepath.Join("public")), "javascripts", "stylesheets", "images", "dist", "fonts", "vendors", "favicon.ico"), })) if *compileTemplate { bindatafs.AssetFS.Compile() } else { fmt.Printf("Listening on: %v\n", config.Config.Port) if config.Config.HTTPS { if err := http.ListenAndServeTLS(fmt.Sprintf(":%d", config.Config.Port), ".config/certs/server.crt", ".config/certs/server.key", Application.NewServeMux()); err != nil { panic(err) } } else { if err := http.ListenAndServe(fmt.Sprintf(":%d", config.Config.Port), Application.NewServeMux()); err != nil { panic(err) } } } }
Ref. https://github.com/qorpress/qorpress-example
Any ways to fix it ? Thanks for your insights and inputs up-front.
Cheers, X
Hi guys,
Hope you are doing well !
I have this error while running the demo.
Ref. https://github.com/qorpress/qorpress-example
Any ways to fix it ? Thanks for your insights and inputs up-front.
Cheers, X