mirror of
https://github.com/stashapp/stash.git
synced 2025-12-18 04:44:37 +03:00
Configuration
* Added flags to customize the host and port * Start up just one server rather than a server for HTTP and HTTPS. HTTPS server will only start if a cert and key are found
This commit is contained in:
@@ -12,6 +12,9 @@ const Downloads = "downloads"
|
||||
|
||||
const Database = "database"
|
||||
|
||||
const Host = "host"
|
||||
const Port = "port"
|
||||
|
||||
func Set(key string, value interface{}) {
|
||||
viper.Set(key, value)
|
||||
}
|
||||
@@ -40,6 +43,14 @@ func GetDatabasePath() string {
|
||||
return viper.GetString(Database)
|
||||
}
|
||||
|
||||
func GetHost() string {
|
||||
return viper.GetString(Host)
|
||||
}
|
||||
|
||||
func GetPort() int {
|
||||
return viper.GetInt(Port)
|
||||
}
|
||||
|
||||
func IsValid() bool {
|
||||
setPaths := viper.IsSet(Stash) && viper.IsSet(Cache) && viper.IsSet(Generated) && viper.IsSet(Metadata)
|
||||
// TODO: check valid paths
|
||||
|
||||
@@ -3,12 +3,14 @@ package manager
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/fsnotify/fsnotify"
|
||||
"github.com/spf13/pflag"
|
||||
"github.com/spf13/viper"
|
||||
"github.com/stashapp/stash/pkg/ffmpeg"
|
||||
"github.com/stashapp/stash/pkg/logger"
|
||||
"github.com/stashapp/stash/pkg/manager/config"
|
||||
"github.com/stashapp/stash/pkg/manager/paths"
|
||||
"github.com/stashapp/stash/pkg/utils"
|
||||
"net"
|
||||
"sync"
|
||||
)
|
||||
|
||||
@@ -33,6 +35,7 @@ func Initialize() *singleton {
|
||||
once.Do(func() {
|
||||
_ = utils.EnsureDir(paths.GetConfigDirectory())
|
||||
initConfig()
|
||||
initFlags()
|
||||
instance = &singleton{
|
||||
Status: Idle,
|
||||
Paths: paths.NewPaths(),
|
||||
@@ -78,6 +81,16 @@ func initConfig() {
|
||||
//viper.WriteConfig()
|
||||
}
|
||||
|
||||
func initFlags() {
|
||||
pflag.IP("host", net.IPv4(0, 0, 0, 0), "ip address for the host")
|
||||
pflag.Int("port", 9999, "port to serve from")
|
||||
|
||||
pflag.Parse()
|
||||
if err := viper.BindPFlags(pflag.CommandLine); err != nil {
|
||||
logger.Infof("failed to bind flags: %s", err.Error())
|
||||
}
|
||||
}
|
||||
|
||||
func initFFMPEG() {
|
||||
configDirectory := paths.GetConfigDirectory()
|
||||
ffmpegPath, ffprobePath := ffmpeg.GetPaths(configDirectory)
|
||||
|
||||
@@ -36,3 +36,11 @@ func GetDefaultDatabaseFilePath() string {
|
||||
func GetDefaultConfigFilePath() string {
|
||||
return filepath.Join(GetConfigDirectory(), "config.yml")
|
||||
}
|
||||
|
||||
func GetSSLKey() string {
|
||||
return filepath.Join(GetConfigDirectory(), "stash.key")
|
||||
}
|
||||
|
||||
func GetSSLCert() string {
|
||||
return filepath.Join(GetConfigDirectory(), "stash.crt")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user