|
@@ -31,13 +31,21 @@ func init() {
|
|
}
|
|
}
|
|
|
|
|
|
func main() {
|
|
func main() {
|
|
|
|
+ // Init logger
|
|
|
|
+ lg := logger.New()
|
|
|
|
+ defer lg.Close()
|
|
|
|
+
|
|
|
|
+ // Check www dir
|
|
ParamWwwDir = utils.FixPath(ParamWwwDir)
|
|
ParamWwwDir = utils.FixPath(ParamWwwDir)
|
|
if !utils.IsHostDirExists(ParamWwwDir) {
|
|
if !utils.IsHostDirExists(ParamWwwDir) {
|
|
- fmt.Println("Virtual hosts directory is not exists")
|
|
|
|
- fmt.Println("Example: ./fave -host 127.0.0.1 -port 80 -dir ./hosts")
|
|
|
|
|
|
+ lg.Log("Virtual hosts directory is not exists")
|
|
|
|
+ lg.Log("Example: ./fave -host 127.0.0.1 -port 80 -dir ./hosts")
|
|
return
|
|
return
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ // Attach www dir to logger
|
|
|
|
+ lg.SetWwwDir(ParamWwwDir)
|
|
|
|
+
|
|
// Init mounted resources
|
|
// Init mounted resources
|
|
res := resource.New()
|
|
res := resource.New()
|
|
res.Add(consts.AssetsCpScriptsJs, "application/javascript; charset=utf-8", assets.CpScriptsJs)
|
|
res.Add(consts.AssetsCpScriptsJs, "application/javascript; charset=utf-8", assets.CpScriptsJs)
|
|
@@ -52,7 +60,7 @@ func main() {
|
|
stat := static.New(consts.DirIndexFile)
|
|
stat := static.New(consts.DirIndexFile)
|
|
|
|
|
|
// Init and start web server
|
|
// Init and start web server
|
|
- bootstrap.Start(logger.New, fmt.Sprintf("%s:%d", ParamHost, ParamPort), 30, consts.AssetsPath, func(w http.ResponseWriter, r *http.Request) {
|
|
|
|
|
|
+ bootstrap.Start(lg.Handler, fmt.Sprintf("%s:%d", ParamHost, ParamPort), 30, consts.AssetsPath, func(w http.ResponseWriter, r *http.Request) {
|
|
w.Header().Set("Server", "fave.pro/"+consts.ServerVersion)
|
|
w.Header().Set("Server", "fave.pro/"+consts.ServerVersion)
|
|
}, func(w http.ResponseWriter, r *http.Request) {
|
|
}, func(w http.ResponseWriter, r *http.Request) {
|
|
// Mounted assets
|
|
// Mounted assets
|
|
@@ -114,6 +122,9 @@ func main() {
|
|
utils.SystemErrorPage404(w)
|
|
utils.SystemErrorPage404(w)
|
|
})
|
|
})
|
|
|
|
|
|
|
|
+ // Close logger
|
|
|
|
+ //lg.Close()
|
|
|
|
+
|
|
// TODO: call it in background time by time
|
|
// TODO: call it in background time by time
|
|
// Delete expired session files
|
|
// Delete expired session files
|
|
// session.Clean("./tmp")
|
|
// session.Clean("./tmp")
|