func shutdownModules() {
	for i := len(modulesArr) - 1; i >= 0; i-- {
		modulesArr[i].module.BeforeShutdown()
	}
	for i := len(modulesArr) - 1; i >= 0; i-- {
		name := modulesArr[i].name
		mod := modulesArr[i].module
		logger.Log.Debugf("stopping module: %s", name)
		if err := mod.Shutdown(); err != nil {
			logger.Log.Warnf("error stopping module: %s", name)
		}
		logger.Log.Infof("module: %s stopped!", name)
	}
}
shutdownModules starts all modules in reverse order
package pitaya
import (
	"fmt"
	"github.com/topfreegames/pitaya/interfaces"
	"github.com/topfreegames/pitaya/logger"
)
var (
	modulesMap = make(map[string]interfaces.Module)  
	modulesArr = []moduleWrapper{}                   
)
type moduleWrapper struct {
	module interfaces.Module
	name   string
}
func RegisterModule(module interfaces.Module, name string) error {
	return RegisterModuleAfter(module, name)
}
func RegisterModuleAfter(module interfaces.Module, name string) error {
	if err := alreadyRegistered(name); err != nil {
		return err
	}
	modulesMap[name] = module
	modulesArr = append(modulesArr, moduleWrapper{
		module: module,
		name:   name,
	})
	return nil
}
func RegisterModuleBefore(module interfaces.Module, name string) error {
	if err := alreadyRegistered(name); err != nil {
		return err
	}
	modulesMap[name] = module
	modulesArr = append([]moduleWrapper{
		{
			module: module,
			name:   name,
		},
	}, modulesArr...)
	return nil
}
func GetModule(name string) (interfaces.Module, error) {
	if m, ok := modulesMap[name]; ok {
		return m, nil
	}
	return nil, fmt.Errorf("module with name %s not found", name)
}
func alreadyRegistered(name string) error {
	if _, ok := modulesMap[name]; ok {
		return fmt.Errorf("module with name %s already exists", name)
	}
	return nil
}
func startModules() {
	logger.Log.Debug("initializing all modules")
	for _, modWrapper := range modulesArr {
		logger.Log.Debugf("initializing module: %s", modWrapper.name)
		if err := modWrapper.module.Init(); err != nil {
			logger.Log.Fatalf("error starting module %s, error: %s", modWrapper.name, err.Error())
		}
	}
	for _, modWrapper := range modulesArr {
		modWrapper.module.AfterInit()
		logger.Log.Infof("module: %s successfully loaded", modWrapper.name)
	}
}