Allow more parameters to be passed in environment
This commit is contained in:
parent
48fe1e7711
commit
afcc7f2de0
3 changed files with 106 additions and 37 deletions
|
@ -10,6 +10,7 @@ import (
|
|||
"os/signal"
|
||||
"path"
|
||||
"path/filepath"
|
||||
"strconv"
|
||||
"strings"
|
||||
"syscall"
|
||||
|
||||
|
@ -62,6 +63,8 @@ func StripPrefix(prefix string, h http.Handler) http.Handler {
|
|||
}
|
||||
|
||||
func main() {
|
||||
var err error
|
||||
bind := "127.0.0.1:8081"
|
||||
cloudDAVBase := ""
|
||||
cloudUsername := "fic"
|
||||
cloudPassword := ""
|
||||
|
@ -95,11 +98,53 @@ func main() {
|
|||
baseURL = v
|
||||
}
|
||||
if v, exists := os.LookupEnv("FIC_4REAL"); exists {
|
||||
api.IsProductionEnv = v == "true" || v == "on" || v == "TRUE" || v == "ON" || v == "1"
|
||||
api.IsProductionEnv, err = strconv.ParseBool(v)
|
||||
if err != nil {
|
||||
log.Fatal("Unable to parse FIC_4REAL variable:", err)
|
||||
}
|
||||
}
|
||||
if v, exists := os.LookupEnv("FIC_ADMIN_BIND"); exists {
|
||||
bind = v
|
||||
}
|
||||
if v, exists := os.LookupEnv("FIC_TIMESTAMPCHECK"); exists {
|
||||
api.TimestampCheck = v
|
||||
}
|
||||
if v, exists := os.LookupEnv("FIC_SETTINGS"); exists {
|
||||
settings.SettingsDir = v
|
||||
}
|
||||
if v, exists := os.LookupEnv("FIC_FILES"); exists {
|
||||
fic.FilesDir = v
|
||||
}
|
||||
if v, exists := os.LookupEnv("FIC_SYNC_LOCALIMPORT"); exists {
|
||||
localImporterDirectory = v
|
||||
}
|
||||
if v, exists := os.LookupEnv("FIC_SYNC_LOCALIMPORTSYMLINK"); exists {
|
||||
localImporterSymlink, err = strconv.ParseBool(v)
|
||||
if err != nil {
|
||||
log.Fatal("Unable to parse FIC_SYNC_LOCALIMPORTSYMLINK variable:", err)
|
||||
}
|
||||
}
|
||||
if v, exists := os.LookupEnv("FIC_SYNC_GIT_IMPORT_REMOTE"); exists {
|
||||
gitImporterRemote = v
|
||||
}
|
||||
if v, exists := os.LookupEnv("FIC_SYNC_GIT_BRANCH"); exists {
|
||||
gitImporterBranch = v
|
||||
}
|
||||
if v, exists := os.LookupEnv("FIC_OPTIONALDIGEST"); exists {
|
||||
fic.OptionalDigest, err = strconv.ParseBool(v)
|
||||
if err != nil {
|
||||
log.Fatal("Unable to parse FIC_OPTIONALDIGEST variable:", err)
|
||||
}
|
||||
}
|
||||
if v, exists := os.LookupEnv("FIC_STRONGDIGEST"); exists {
|
||||
fic.StrongDigest, err = strconv.ParseBool(v)
|
||||
if err != nil {
|
||||
log.Fatal("Unable to parse FIC_STRONGDIGEST variable:", err)
|
||||
}
|
||||
}
|
||||
|
||||
// Read parameters from command line
|
||||
var bind = flag.String("bind", "127.0.0.1:8081", "Bind port/socket")
|
||||
flag.StringVar(&bind, "bind", bind, "Bind port/socket")
|
||||
var dsn = flag.String("dsn", fic.DSNGenerator(), "DSN to connect to the MySQL server")
|
||||
flag.StringVar(&baseURL, "baseurl", baseURL, "URL prepended to each URL")
|
||||
flag.StringVar(&api.TimestampCheck, "timestampCheck", api.TimestampCheck, "Path regularly touched by frontend to check time synchronisation")
|
||||
|
@ -169,7 +214,6 @@ func main() {
|
|||
}
|
||||
|
||||
// Sanitize options
|
||||
var err error
|
||||
log.Println("Checking paths...")
|
||||
if staticDir != nil && *staticDir != "" {
|
||||
if sDir, err := filepath.Abs(*staticDir); err != nil {
|
||||
|
@ -265,7 +309,7 @@ func main() {
|
|||
interrupt := make(chan os.Signal, 1)
|
||||
signal.Notify(interrupt, os.Interrupt, syscall.SIGTERM)
|
||||
|
||||
app := NewApp(config, baseURL, *bind)
|
||||
app := NewApp(config, baseURL, bind)
|
||||
go app.Start()
|
||||
|
||||
// Wait shutdown signal
|
||||
|
|
Reference in a new issue