- Timestamp:
- Jan 21, 2024, 3:23:44 AM (17 months ago)
- Location:
- trunk/cmd/mai
- Files:
-
- 1 added
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/cmd/mai/flag.go
r59 r63 8 8 func parseFlags() { 9 9 flag.StringVar(&configfile, "f", "", "Configuration file") 10 flag.BoolVar(&verbose, "v", false, "Verbose logging") 10 11 flag.Parse() 11 12 } -
trunk/cmd/mai/main.go
r62 r63 3 3 import ( 4 4 "bytes" 5 "fmt" 5 6 "net/http" 6 7 "net/url" … … 8 9 "time" 9 10 "runtime" 10 11 "syscall" 12 13 "marisa.chaotic.ninja/mai" 11 14 "marisa.chaotic.ninja/mai/engines" 15 12 16 "github.com/gofiber/fiber/v2" 13 17 "github.com/gofiber/fiber/v2/middleware/logger" … … 17 21 var ( 18 22 configfile string 23 verbose bool 19 24 ) 20 25 var conf struct { 26 group string 21 27 listen string 22 redisuri string23 28 staticpath string 24 29 tmplpath string 30 user string 25 31 } 26 32 func main() { … … 28 34 29 35 if configfile != "" { 36 if verbose { 37 fmt.Printf("[mai] Reading configuration file") 38 } 30 39 readConf(configfile) 31 40 } … … 35 44 conf.staticpath = "./static" 36 45 conf.tmplpath = "./views" 46 47 if conf.user != "" { 48 if verbose { 49 fmt.Printf("[mai] Dropping privileges to %s", conf.user) 50 } 51 uid, gid, err := usergroupids(conf.user, conf.group) 52 if err != nil { 53 fmt.Println(err) 54 os.Exit(1) 55 } 56 syscall.Setuid(uid) 57 syscall.Setgid(gid) 58 } 37 59 38 60 engine := html.New(conf.tmplpath, ".html") … … 266 288 }) 267 289 app.Listen(conf.listen) 290 291 if verbose { 292 fmt.Printf("Starting mai %v\n", mai.FullVersion()) 293 fmt.Printf("Listening on %s", conf.listen) 294 } 268 295 } -
trunk/cmd/mai/readconf.go
r61 r63 12 12 } 13 13 14 conf.group = cfg.Section("mai").Key("group").String() 14 15 conf.listen = cfg.Section("mai").Key("listen").String() 15 16 conf.staticpath = cfg.Section("mai").Key("static").String() 16 17 conf.tmplpath = cfg.Section("mai").Key("templates").String() 18 conf.user = cfg.Section("mai").Key("user").String() 17 19 18 20 return nil
Note:
See TracChangeset
for help on using the changeset viewer.