apache_conf config.json

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了apache_conf config.json相关的知识,希望对你有一定的参考价值。

package main

import (
	"encoding/json"
	// boshdir "github.com/cloudfoundry/bosh-cli/director"
	bosherr "github.com/cloudfoundry/bosh-utils/errors"
	boshlog "github.com/cloudfoundry/bosh-utils/logger"
	boshsys "github.com/cloudfoundry/bosh-utils/system"
	turbulence_director "github.com/cppforlife/turbulence/director"
	// alias "github.com/cppforlife/turbulence/main"
	"github.com/davecgh/go-spew/spew"
	"os"
)

func main() {
	logger := boshlog.NewWriterLogger(boshlog.LevelDebug, os.Stderr, os.Stderr)
	fs := boshsys.NewOsFileSystem(logger)
	config, err := NewConfigFromPath("config.json", fs)
	if err != nil {
		logger.Error("tag", err.Error())
	}

	spew.Dump(config)
	factory := turbulence_director.NewFactory(config, logger)
	director, err := factory.New()
	if err != nil {
		logger.Error("tag", err.Error())
	}
	spew.Dump(director.AllInstances())
}

type Config struct {
	ListenAddress string
	ListenPort    int

	Username string
	Password string

	CertificatePath string
	PrivateKeyPath  string

	Director turbulence_director.Config

	// Datadog reporter.DatadogConfig
}

func NewConfigFromPath(path string, fs boshsys.FileSystem) (turbulence_director.Config, error) {
	var config Config

	bytes, err := fs.ReadFile(path)
	if err != nil {
		return turbulence_director.Config{}, bosherr.WrapErrorf(err, "Reading config %s", path)
	}
	err = json.Unmarshal(bytes, &config)
	if err != nil {
		return turbulence_director.Config{}, bosherr.WrapError(err, "Unmarshalling config")
	}

	return config.Director, nil
}
{
  "ListenAddress": "0.0.0.0",
  "ListenPort": 8080,
  "Username": "turbulence",
  "Password": "generated-password",
  "CertificatePath": "/var/vcap/jobs/turbulence_api/config/cert",
  "PrivateKeyPath": "/var/vcap/jobs/turbulence_api/config/private_key",
  "Director": {
    "Host": "some-bosh-ip-address",
    "Port": 25555,
    "CACert": "-----BEGIN CERTIFICATE-----\nFAKEFAKEFAKEFAKEFAKEFAKEFAKE\nFAKEFAKEFAKEFAKEFAKEFAKE\nFAKEFAKEFAKEFAKEFAKEFAKEFAKEFAKE\nFAKEFAKEFAKEFAKEFAKEFAKEFAKEFAKEFAKE\n-----END CERTIFICATE-----\n",
    "Client": "director",
    "ClientSecret": "director-client-secret"
  },
  "Datadog": {
    "AppKey": "",
    "APIKey": ""
  }
}

以上是关于apache_conf config.json的主要内容,如果未能解决你的问题,请参考以下文章

apache_conf config.json

apache_conf config.json

apache_conf config.json

apache_conf 〜/ .homebridge / config.json

apache_conf config.json用于测试复杂的json解析器

apache_conf Sequelize config.json用于不同的数据库