Introduce #version

This commit is contained in:
Gregory Eremin 2014-07-29 13:31:42 +07:00
parent 37aacf973b
commit 69497c77e4
3 changed files with 8 additions and 3 deletions

View File

@ -13,14 +13,14 @@ var (
func SetupLogging() { func SetupLogging() {
logger = log.New(os.Stdout, "", log.Ldate|log.Lmicroseconds) logger = log.New(os.Stdout, "", log.Ldate|log.Lmicroseconds)
Log("Burlesque started in %s environment", Config.Env) Log("Burlesque v%s started in %s environment", Version, Config.Env)
Log("GOMAXPROCS is set to %d", runtime.GOMAXPROCS(-1)) Log("GOMAXPROCS is set to %d", runtime.GOMAXPROCS(-1))
Log("Storage path: %s", Config.Storage) Log("Storage path: %s", Config.Storage)
Log("Server is running at http://127.0.0.1:%d", Config.Port) Log("Server is running at http://127.0.0.1:%d", Config.Port)
} }
func Log(format string, args ...interface{}) { func Log(format string, args ...interface{}) {
logger.Printf("[INFO] "+format, args...) logger.Printf("[INFO] "+format, args...)
} }
func Debug(format string, args ...interface{}) { func Debug(format string, args ...interface{}) {
@ -35,6 +35,6 @@ func Error(err error, format string, args ...interface{}) {
if Config.Env == "development" { if Config.Env == "development" {
panic(err) panic(err)
} else { } else {
logger.Printf(" ", err.Error()) logger.Printf(" ", err.Error())
} }
} }

View File

@ -8,6 +8,10 @@ import (
"syscall" "syscall"
) )
const (
Version = "0.1.3"
)
func HandleShutdown() { func HandleShutdown() {
ch := make(chan os.Signal) ch := make(chan os.Signal)
signal.Notify(ch, os.Interrupt, os.Kill, syscall.SIGTERM, syscall.SIGINT) signal.Notify(ch, os.Interrupt, os.Kill, syscall.SIGTERM, syscall.SIGINT)

View File

@ -30,6 +30,7 @@ func StatusHandler(w http.ResponseWriter, r *http.Request) {
func DebugHandler(w http.ResponseWriter, r *http.Request) { func DebugHandler(w http.ResponseWriter, r *http.Request) {
info := make(map[string]interface{}) info := make(map[string]interface{})
info["version"] = Version
info["goroutines"] = runtime.NumGoroutine() info["goroutines"] = runtime.NumGoroutine()
s, err := storage.Status() s, err := storage.Status()