func InitRuntime(root string, chainId string) error {
	root = RuntimeDir(root)
	err := cmn.EnsureDir(root, 0700)
	if err != nil {
		return err
	}
	_ = cmn.EnsureDir(path.Join(root, DATADIR), 0700)
	configFilePath := path.Join(root, CONFIGFILE)
	if cmn.FileExists(configFilePath) {
		return errors.New("config.toml already exists!")
	}
	fmt.Println("Using config file:", configFilePath)
	err = cmn.WriteFile(configFilePath, []byte(parseConfigTpl("anonymous", root)), 0644)
	if err != nil {
		return err
	}
	conf := viper.New()
	SetDefaults(root, conf)
	conf.AutomaticEnv()
	genPrivFile(conf.GetString("priv_validator_file"))
	genDoc, err := genGenesiFile(conf.GetString("genesis_file"), chainId, nil)
	if err != nil {
		return err
	}
	fmt.Println("Initialized ", genDoc.ChainID, "genesis", conf.GetString("genesis_file"), "priv_validator", conf.GetString("priv_validator_file"))
	fmt.Println("Check the files generated, make sure everything is OK.")
	return nil
}
InitRuntimeDir makes all the necessary directorys for angine's runtime
and generate the config template for you if it is not there already
package config
import (
	"fmt"
	"os"
	"path"
	"strings"
	homedir "github.com/mitchellh/go-homedir"
	"github.com/pkg/errors"
	"github.com/spf13/viper"
	"github.com/annchain/annchain/angine/types"
	cmn "github.com/annchain/annchain/module/lib/go-common"
)
const (
	RUNTIME_ENV = "ANGINE_RUNTIME"
	DEFAULT_RUNTIME = ".angine"
	DATADIR = "data"
	CONFIGFILE = "config.toml"
)
var runtimePath string
func parseConfigTpl(moniker string, root string) (conf string) {
	conf = strings.Replace(CONFIGTPL, "__MONIKER__", moniker, -1)
	return
}
func RuntimeDir(root string) string {
	if root != "" {
		return root
	}
	runtimePath := os.Getenv(RUNTIME_ENV)
	if len(runtimePath) == 0 {
		runtimePath, _ = homedir.Dir()
	}
	return path.Join(runtimePath, DEFAULT_RUNTIME)
}