config

package
v1.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 28, 2017 License: Apache-2.0 Imports: 26 Imported by: 0

Documentation

Overview

Copyright 2016 Wenhui Shen <www.webx.top>

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Copyright 2016 Wenhui Shen <www.webx.top>

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Copyright 2016 Wenhui Shen <www.webx.top>

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Copyright 2016 Wenhui Shen <www.webx.top>

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Copyright 2016 Wenhui Shen <www.webx.top>

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Index

Constants

This section is empty.

Variables

View Source
var (
	Installed             sql.NullBool
	DefaultConfig         = &Config{}
	DefaultCLIConfig      = &CLIConfig{cmds: map[string]*exec.Cmd{}}
	ErrUnknowDatabaseType = errors.New(`unkown database type`)
)
View Source
var (
	SessionOptions *echo.SessionOptions
	CookieOptions  *cookie.CookieOptions
)
View Source
var (
	DBConnecters = map[string]func(*Config) error{
		`mysql`: ConnectMySQL,
		`mongo`: ConnectMongoDB,
	}
	DBInstallers = map[string]func(string) error{
		`mysql`: ExecMySQL,
	}
	DBCreaters = map[string]func(error, *Config) error{
		`mysql`: CreaterMySQL,
	}
	DBEngines = echo.NewKVData().Add(`mysql`, `MySQL`)
)
View Source
var ErrCmdNotRunning = errors.New(`command is not running`)

Functions

func CmdIsRunning

func CmdIsRunning(cmd *exec.Cmd) bool

func ConnectDB

func ConnectDB() error

func ConnectMongoDB added in v1.1.0

func ConnectMongoDB(c *Config) error

func ConnectMySQL added in v1.1.0

func ConnectMySQL(c *Config) error

func CreaterMySQL added in v1.1.0

func CreaterMySQL(err error, c *Config) error

func ExecMySQL added in v1.1.0

func ExecMySQL(sqlStr string) error

func InitLog

func InitLog()

func InitSessionOptions

func InitSessionOptions()

func IsInstalled

func IsInstalled() bool

func MustOK

func MustOK(err error)

func ParseConfig

func ParseConfig() error

func ParseTimeDuration

func ParseTimeDuration(timeout string) time.Duration

func SetVersion

func SetVersion(version string)

func Version

func Version() string

Types

type CLIConfig

type CLIConfig struct {
	Port    int
	Conf    string
	Type    string //启动类型: webserver/ftpserver/manager
	Startup string //manager启动时同时启动的服务,可选的有webserver/ftpserver,如有多个需用半角逗号“,”隔开
	// contains filtered or unexported fields
}

func (*CLIConfig) CaddyRestart

func (c *CLIConfig) CaddyRestart(writer ...io.Writer) error

func (*CLIConfig) CaddyStart

func (c *CLIConfig) CaddyStart(writer ...io.Writer) (err error)

func (*CLIConfig) CaddyStop

func (c *CLIConfig) CaddyStop() error

func (*CLIConfig) CaddyStopHistory

func (c *CLIConfig) CaddyStopHistory() (err error)

func (*CLIConfig) CmdStop

func (c *CLIConfig) CmdStop(typeName string) error

func (*CLIConfig) FTPRestart

func (c *CLIConfig) FTPRestart(writer ...io.Writer) error

func (*CLIConfig) FTPStart

func (c *CLIConfig) FTPStart(writer ...io.Writer) (err error)

func (*CLIConfig) FTPStop

func (c *CLIConfig) FTPStop() error

func (*CLIConfig) FTPStopHistory

func (c *CLIConfig) FTPStopHistory() (err error)

func (*CLIConfig) InitFlag

func (c *CLIConfig) InitFlag()

func (*CLIConfig) IsRunning

func (c *CLIConfig) IsRunning(ct string) bool

func (*CLIConfig) OnlyRunServer

func (c *CLIConfig) OnlyRunServer() bool

func (*CLIConfig) Reload

func (c *CLIConfig) Reload() error

func (*CLIConfig) RunStartup

func (c *CLIConfig) RunStartup()

RunStartup manager启动时同时启动的服务

func (*CLIConfig) SetLogWriter

func (c *CLIConfig) SetLogWriter(cmdType string, writer ...io.Writer) error

type Config

type Config struct {
	DB struct {
		Type     string            `json:"type"`
		User     string            `json:"user"`
		Password string            `json:"password"`
		Host     string            `json:"host"`
		Database string            `json:"database"`
		Prefix   string            `json:"prefix"`
		Options  map[string]string `json:"options"`
		Debug    bool              `json:"debug"`
	} `json:"db"`

	Log struct {
		Debug        bool   `json:"debug"`
		Colorable    bool   `json:"colorable"`    // for console
		SaveFile     string `json:"saveFile"`     // for file
		FileMaxBytes int64  `json:"fileMaxBytes"` // for file
		Targets      string `json:"targets"`
	} `json:"log"`

	Sys struct {
		VhostsfileDir          string            `json:"vhostsfileDir"`
		AllowIP                []string          `json:"allowIP"`
		SSLHosts               []string          `json:"sslHosts"`
		SSLCacheDir            string            `json:"sslCacheDir"`
		SSLKeyFile             string            `json:"sslKeyFile"`
		SSLCertFile            string            `json:"sslCertFile"`
		Debug                  bool              `json:"debug"`
		EditableFileExtensions map[string]string `json:"editableFileExtensions"`
		EditableFileMaxSize    string            `json:"editableFileMaxSize"`
		EditableFileMaxBytes   int64             `json:"editableFileMaxBytes"`
		ErrorPages             map[int]string    `json:"errorPages"`
		CmdTimeout             string            `json:"cmdTimeout"`
		CmdTimeoutDuration     time.Duration     `json:"-"`
	} `json:"sys"`

	Email struct {
		*mail.SMTPConfig
		Timeout   int64  //超时时间(秒),采用默认引擎发信时,此项无效
		Engine    string //值为email时采用github.com/jordan-wright/email包发送,否则采用默认的github.com/admpub/mail发送
		From      string //发信人Email地址
		QueueSize int    //允许同一时间发信的数量
	} `json:"email"`

	Cron struct {
		PoolSize int    `json:"poolSize"`
		Template string `json:"template"` //发信模板
	} `json:"cron"`

	Cookie struct {
		Domain   string `json:"domain"`
		MaxAge   int    `json:"maxAge"`
		Path     string `json:"path"`
		HttpOnly bool   `json:"httpOnly"`
		HashKey  string `json:"hashKey"`
		BlockKey string `json:"blockKey"`
	} `json:"cookie"`

	Caddy    caddy.Config    `json:"caddy"`
	FTP      ftp.Config      `json:"ftp"`
	Language language.Config `json:"language"`
	Download struct {
		SavePath string `json:"savePath"`
	} `json:"download"`
}

func (*Config) SaveToFile

func (c *Config) SaveToFile() error

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL