mirror of
https://github.com/stashapp/stash.git
synced 2025-12-17 20:34:37 +03:00
@@ -17,18 +17,20 @@ var once sync.Once
|
||||
|
||||
type flagStruct struct {
|
||||
configFilePath string
|
||||
cpuProfilePath string
|
||||
}
|
||||
|
||||
func Initialize() (*Instance, error) {
|
||||
var err error
|
||||
once.Do(func() {
|
||||
instance = &Instance{}
|
||||
|
||||
flags := initFlags()
|
||||
instance = &Instance{
|
||||
cpuProfilePath: flags.cpuProfilePath,
|
||||
}
|
||||
|
||||
if err = initConfig(flags); err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
initEnvs()
|
||||
|
||||
if instance.isNewSystem {
|
||||
@@ -46,6 +48,7 @@ func Initialize() (*Instance, error) {
|
||||
}
|
||||
|
||||
func initConfig(flags flagStruct) error {
|
||||
|
||||
// The config file is called config. Leave off the file extension.
|
||||
viper.SetConfigName("config")
|
||||
|
||||
@@ -98,6 +101,7 @@ func initFlags() flagStruct {
|
||||
pflag.IP("host", net.IPv4(0, 0, 0, 0), "ip address for the host")
|
||||
pflag.Int("port", 9999, "port to serve from")
|
||||
pflag.StringVarP(&flags.configFilePath, "config", "c", "", "config file to use")
|
||||
pflag.StringVar(&flags.cpuProfilePath, "cpuprofile", "", "write cpu profile to file")
|
||||
|
||||
pflag.Parse()
|
||||
if err := viper.BindPFlags(pflag.CommandLine); err != nil {
|
||||
|
||||
Reference in New Issue
Block a user