53 lines
1.3 KiB
Go
Executable File
53 lines
1.3 KiB
Go
Executable File
package config
|
|
|
|
import (
|
|
"fmt"
|
|
"local/args"
|
|
"os"
|
|
"strings"
|
|
"time"
|
|
)
|
|
|
|
var (
|
|
Port string
|
|
StoreType string
|
|
StoreAddr string
|
|
StoreUser string
|
|
StorePass string
|
|
Root string
|
|
OAuth string
|
|
Loop time.Duration
|
|
)
|
|
|
|
func init() {
|
|
Refresh()
|
|
}
|
|
|
|
func Refresh() {
|
|
if strings.Contains(fmt.Sprint(os.Args), "-test") {
|
|
return
|
|
}
|
|
|
|
as := args.NewArgSet()
|
|
as.Append(args.STRING, "port", "port to listen on", "39909")
|
|
as.Append(args.STRING, "store", "type of store", "map")
|
|
as.Append(args.STRING, "storeaddr", "addr of store", "")
|
|
as.Append(args.STRING, "storeuser", "user of store", "")
|
|
as.Append(args.STRING, "storepass", "pass of store", "")
|
|
as.Append(args.STRING, "oauth", "url for boauthz", "")
|
|
as.Append(args.STRING, "root", "root of static files", "./public")
|
|
as.Append(args.DURATION, "loop", "loop duration for refreshing completed tasks", time.Minute)
|
|
if err := as.Parse(); err != nil {
|
|
panic(err)
|
|
}
|
|
|
|
Port = ":" + strings.TrimPrefix(as.Get("port").GetString(), ":")
|
|
StoreType = as.Get("store").GetString()
|
|
StoreAddr = as.Get("storeaddr").GetString()
|
|
StoreUser = as.Get("storeuser").GetString()
|
|
StorePass = as.Get("storepass").GetString()
|
|
Root = as.Get("root").GetString()
|
|
Loop = as.Get("loop").GetDuration()
|
|
OAuth = as.Get("oauth").GetString()
|
|
}
|