feat(mode): add demo mode (#1121)

* feat(mode): add demo mode

* chroe: Update store/db/db.go

Co-authored-by: boojack <stevenlgtm@gmail.com>

* chroe: Update store/db/db.go

Co-authored-by: boojack <stevenlgtm@gmail.com>

---------

Co-authored-by: boojack <stevenlgtm@gmail.com>
This commit is contained in:
Yoshino-s
2023-02-19 13:36:45 +08:00
committed by GitHub
parent d0b8b076cf
commit afaaec8492
9 changed files with 27 additions and 23 deletions

View File

@ -12,7 +12,7 @@ import (
// Profile is the configuration to start main server.
type Profile struct {
// Mode can be "prod" or "dev"
// Mode can be "prod" or "dev" or "demo"
Mode string `json:"mode"`
// Port is the binding port for server
Port int `json:"-"`
@ -47,13 +47,13 @@ func checkDSN(dataDir string) (string, error) {
// GetDevProfile will return a profile for dev or prod.
func GetProfile() (*Profile, error) {
profile := Profile{}
flag.StringVar(&profile.Mode, "mode", "dev", "mode of server")
flag.StringVar(&profile.Mode, "mode", "demo", "mode of server")
flag.IntVar(&profile.Port, "port", 8081, "port of server")
flag.StringVar(&profile.Data, "data", "", "data directory")
flag.Parse()
if profile.Mode != "dev" && profile.Mode != "prod" {
profile.Mode = "dev"
if profile.Mode != "dev" && profile.Mode != "prod" && profile.Mode != "demo" {
profile.Mode = "demo"
}
if profile.Mode == "prod" && profile.Data == "" {