|
|
|
@ -39,6 +39,7 @@ var (
|
|
|
|
|
Mode: viper.GetString("mode"),
|
|
|
|
|
Addr: viper.GetString("addr"),
|
|
|
|
|
Port: viper.GetInt("port"),
|
|
|
|
|
UNIXSock: viper.GetString("unix-sock"),
|
|
|
|
|
Data: viper.GetString("data"),
|
|
|
|
|
Driver: viper.GetString("driver"),
|
|
|
|
|
DSN: viper.GetString("dsn"),
|
|
|
|
@ -106,6 +107,7 @@ func init() {
|
|
|
|
|
rootCmd.PersistentFlags().String("mode", "dev", `mode of server, can be "prod" or "dev" or "demo"`)
|
|
|
|
|
rootCmd.PersistentFlags().String("addr", "", "address of server")
|
|
|
|
|
rootCmd.PersistentFlags().Int("port", 8081, "port of server")
|
|
|
|
|
rootCmd.PersistentFlags().String("unix-sock", "", "path to the unix socket, overrides --addr and --port")
|
|
|
|
|
rootCmd.PersistentFlags().String("data", "", "data directory")
|
|
|
|
|
rootCmd.PersistentFlags().String("driver", "sqlite", "database driver")
|
|
|
|
|
rootCmd.PersistentFlags().String("dsn", "", "database source name(aka. DSN)")
|
|
|
|
@ -120,6 +122,9 @@ func init() {
|
|
|
|
|
if err := viper.BindPFlag("port", rootCmd.PersistentFlags().Lookup("port")); err != nil {
|
|
|
|
|
panic(err)
|
|
|
|
|
}
|
|
|
|
|
if err := viper.BindPFlag("unix-sock", rootCmd.PersistentFlags().Lookup("unix-sock")); err != nil {
|
|
|
|
|
panic(err)
|
|
|
|
|
}
|
|
|
|
|
if err := viper.BindPFlag("data", rootCmd.PersistentFlags().Lookup("data")); err != nil {
|
|
|
|
|
panic(err)
|
|
|
|
|
}
|
|
|
|
@ -151,16 +156,21 @@ version: %s
|
|
|
|
|
data: %s
|
|
|
|
|
addr: %s
|
|
|
|
|
port: %d
|
|
|
|
|
unix-sock: %s
|
|
|
|
|
mode: %s
|
|
|
|
|
driver: %s
|
|
|
|
|
---
|
|
|
|
|
`, profile.Version, profile.Data, profile.Addr, profile.Port, profile.Mode, profile.Driver)
|
|
|
|
|
`, profile.Version, profile.Data, profile.Addr, profile.Port, profile.UNIXSock, profile.Mode, profile.Driver)
|
|
|
|
|
|
|
|
|
|
print(greetingBanner)
|
|
|
|
|
if len(profile.Addr) == 0 {
|
|
|
|
|
fmt.Printf("Version %s has been started on port %d\n", profile.Version, profile.Port)
|
|
|
|
|
if len(profile.UNIXSock) == 0 {
|
|
|
|
|
if len(profile.Addr) == 0 {
|
|
|
|
|
fmt.Printf("Version %s has been started on port %d\n", profile.Version, profile.Port)
|
|
|
|
|
} else {
|
|
|
|
|
fmt.Printf("Version %s has been started on address '%s' and port %d\n", profile.Version, profile.Addr, profile.Port)
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
fmt.Printf("Version %s has been started on address '%s' and port %d\n", profile.Version, profile.Addr, profile.Port)
|
|
|
|
|
fmt.Printf("Version %s has been started on unix socket %s\n", profile.Version, profile.UNIXSock)
|
|
|
|
|
}
|
|
|
|
|
fmt.Printf(`---
|
|
|
|
|
See more in:
|
|
|
|
|