working commit
This commit is contained in:
+24
-25
@@ -20,32 +20,30 @@ const (
|
||||
pidFilename = "mbased.pid"
|
||||
)
|
||||
|
||||
var (
|
||||
buildVersion = "NONE"
|
||||
)
|
||||
|
||||
type Networks struct {
|
||||
Enabled []string `json:"enabled" yaml:"enabled"`
|
||||
Disabled []string `json:"disabled" yaml:"disabled"`
|
||||
}
|
||||
|
||||
type ServiceConfig struct {
|
||||
type Service struct {
|
||||
Portnum uint32 `json:"port" yaml:"port"`
|
||||
Address string `json:"address" yaml:"address"`
|
||||
Protocol string `json:"protocol" yaml:"protocol"`
|
||||
}
|
||||
|
||||
type Config struct {
|
||||
PackageVersion string `json:"packageVersion" yaml:"packageVersion"`
|
||||
Service ServiceConfig `json:"service" yaml:"service"`
|
||||
Networks Networks `json:"networks" yaml:"networks"`
|
||||
Hostname string `json:"hostname" yaml:"hostname"`
|
||||
Debug bool `json:"debug" yaml:"debug"`
|
||||
Build string `json:"build" yaml:"build"`
|
||||
LogPath string `json:"logfile" yaml:"logfile"`
|
||||
RunPath string `json:"runfile" yaml:"runfile"`
|
||||
DataDir string `json:"datadir" yaml:"datadir"`
|
||||
Daemon bool `json:"daemon" yaml:"daemon"`
|
||||
Version string `json:"version" yaml:"version"`
|
||||
Service Service `json:"service" yaml:"service"`
|
||||
Networks Networks `json:"networks" yaml:"networks"`
|
||||
Hostname string `json:"hostname" yaml:"hostname"`
|
||||
Debug bool `json:"debug" yaml:"debug"`
|
||||
Build string `json:"build" yaml:"build"`
|
||||
LogPath string `json:"logfile" yaml:"logfile"`
|
||||
RunPath string `json:"runfile" yaml:"runfile"`
|
||||
DataDir string `json:"datadir" yaml:"datadir"`
|
||||
AsDaemon bool `json:"asDaemon" yaml:"asDaemon"`
|
||||
RunUser string `json:"runUser" yaml:"runUser"`
|
||||
LogLimit int64 `json:"logLimit" yaml:"logLimit"`
|
||||
}
|
||||
|
||||
var (
|
||||
@@ -54,28 +52,29 @@ var (
|
||||
)
|
||||
|
||||
const (
|
||||
defaultServiceAddress = "0.0.0.0"
|
||||
defaultServiceAddress = "[::]"
|
||||
defaultServiceProtocol = "tcp"
|
||||
)
|
||||
|
||||
func NewConfig() *Config {
|
||||
conf := &Config{
|
||||
Service: ServiceConfig{
|
||||
Service: Service{
|
||||
Portnum: client.DefaultPort,
|
||||
Address: defaultServiceAddress,
|
||||
Protocol: defaultServiceProtocol,
|
||||
},
|
||||
DataDir: datadirPath,
|
||||
Debug: false,
|
||||
Hostname: defaultHostname,
|
||||
Build: buildVersion,
|
||||
Daemon: true,
|
||||
PackageVersion: packageVersion,
|
||||
|
||||
Networks: Networks{
|
||||
Enabled: defaultEnabledNetworks,
|
||||
Disabled: defaultDisabledNetworks,
|
||||
},
|
||||
DataDir: datadirPath,
|
||||
Debug: false,
|
||||
Hostname: defaultHostname,
|
||||
Build: packageVersion,
|
||||
AsDaemon: true,
|
||||
Version: packageVersion,
|
||||
LogLimit: 1024 * 1024 * 10, // 10 Mb
|
||||
RunUser: "daemon",
|
||||
}
|
||||
conf.LogPath = filepath.Join(logdirPath, logFilename)
|
||||
conf.RunPath = filepath.Join(rundirPath, pidFilename)
|
||||
@@ -106,7 +105,7 @@ func (conf *Config) ReadOpts() error {
|
||||
|
||||
exeName := filepath.Base(os.Args[0])
|
||||
|
||||
flag.BoolVar(&conf.Daemon, "daemon", conf.Daemon, "run as daemon")
|
||||
flag.BoolVar(&conf.AsDaemon, "asDaemon", conf.AsDaemon, "run as daemon")
|
||||
flag.BoolVar(&conf.Debug, "debug", conf.Debug, "on debug mode")
|
||||
|
||||
help := func() {
|
||||
|
||||
Reference in New Issue
Block a user