"github.com/gohugoio/hugo/common/hugo"
"github.com/gohugoio/hugo/common/loggers"
"github.com/gohugoio/hugo/common/paths"
+ "github.com/gohugoio/hugo/common/types"
"github.com/gohugoio/hugo/config"
"github.com/gohugoio/hugo/config/allconfig"
"github.com/gohugoio/hugo/deps"
}
args = mapLegacyArgs(args)
cd, err := x.Execute(context.Background(), args)
+ if cd != nil {
+ if closer, ok := cd.Root.Command.(types.Closer); ok {
+ closer.Close()
+ }
+ }
+
if err != nil {
if err == errHelp {
cd.CobraCommand.Help()
return r.logger.Level() <= logg.LevelInfo
}
+func (r *rootCommand) Close() error {
+ if r.hugoSites != nil {
+ r.hugoSites.DeleteFunc(func(key configKey, value *hugolib.HugoSites) bool {
+ if value != nil {
+ value.Close()
+ }
+ return false
+ })
+ }
+ return nil
+}
+
func (r *rootCommand) Build(cd *simplecobra.Commandeer, bcfg hugolib.BuildCfg, cfg config.Provider) (*hugolib.HugoSites, error) {
h, err := r.Hugo(cfg)
if err != nil {
c.r.Println("Error:", err)
}
- if h := c.hugoTry(); h != nil {
- h.Close()
- }
-
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
defer cancel()
wg2, ctx := errgroup.WithContext(ctx)
// TODO(bep) rethink this re. a plugin setup, but this will have to do for now.
WasmDispatchers *warpc.Dispatchers
+ isClosed bool
+
*globalErrHandler
}
}
func (d *Deps) Close() error {
+ if d.isClosed {
+ return nil
+ }
+ d.isClosed = true
+
if d.MemCache != nil {
d.MemCache.Stop()
}