MCPcopy Create free account
hub / github.com/bytebase/bytebase / init

Function init

backend/bin/server/cmd/root.go:89–112  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

87}
88
89func init() {
90 // Set default data directory based on environment.
91 // In Docker, default to /var/opt/bytebase to match the Dockerfile's CMD.
92 // This ensures the data directory is correct even when users add other flags,
93 // which would otherwise cause Docker to replace the entire CMD and lose --data.
94 defaultDataDir := "."
95 if isDocker() {
96 defaultDataDir = "/var/opt/bytebase"
97 }
98
99 // In the release build, Bytebase bundles frontend and backend together and runs on a single port as a mono server.
100 // During development, Bytebase frontend runs on a separate port.
101 rootCmd.PersistentFlags().IntVar(&flags.port, "port", 8080, "port where Bytebase server runs. Default to 80")
102 // When running the release build in production, most of the time, users would not expose Bytebase directly to the public.
103 // Instead they would configure a gateway to forward the traffic to Bytebase. Users need to set --external-url to the address
104 // exposed on that gateway accordingly.
105 rootCmd.PersistentFlags().StringVar(&flags.externalURL, "external-url", "", "the external URL where user visits Bytebase, must start with http:// or https://")
106 rootCmd.PersistentFlags().StringVar(&flags.dataDir, "data", defaultDataDir, "not recommended for production. Directory where Bytebase stores data if PG_URL is not specified. If relative path is supplied, then the path is relative to the directory where Bytebase is under")
107 rootCmd.PersistentFlags().BoolVar(&flags.ha, "ha", false, "run in HA mode")
108 rootCmd.PersistentFlags().BoolVar(&flags.saas, "saas", false, "run in SaaS mode")
109 rootCmd.PersistentFlags().BoolVar(&flags.debug, "debug", false, "enable debug level log")
110 rootCmd.PersistentFlags().BoolVar(&flags.enableJSONLogging, "enable-json-logging", false, "enable output logs in bytebase in json format")
111 rootCmd.PersistentFlags().Uint64Var(&flags.memoryProfileThreshold, "memory-profile-threshold", 0, "the threshold of memory usage in bytes to trigger a memory profile")
112}
113
114// -----------------------------------Command Line Config END--------------------------------------
115

Callers

nothing calls this directly

Calls 1

isDockerFunction · 0.85

Tested by

no test coverage detected