Compare commits
2 Commits
3b3f68c525
...
aeb198e3c1
Author | SHA1 | Date |
---|---|---|
Björn Busse | aeb198e3c1 | |
Björn Busse | e5040eeeac |
|
@ -0,0 +1,2 @@
|
|||
*.swp
|
||||
httptail
|
14
main.go
14
main.go
|
@ -27,15 +27,14 @@ func fileHandler(w http.ResponseWriter, r *http.Request, s string) {
|
|||
sendFile(w, fn, "", "No such file or directory")
|
||||
return
|
||||
}
|
||||
|
||||
fmt.Println("watch: %#v", watch)
|
||||
if (watch == false) {
|
||||
t, err := tail.TailFile(fn, tail.Config{Follow: false})
|
||||
t, err := tail.TailFile(fn, tail.Config{Follow: false, MustExist: true})
|
||||
watch = true
|
||||
}
|
||||
|
||||
if (err == nil) {
|
||||
fmt.Println(err)
|
||||
}
|
||||
}
|
||||
|
||||
var m = ""
|
||||
|
||||
|
@ -52,10 +51,10 @@ func fileHandler(w http.ResponseWriter, r *http.Request, s string) {
|
|||
}
|
||||
|
||||
func sendFile(w http.ResponseWriter, fn string, m string, err string) {
|
||||
json.NewEncoder(w).Encode(map[string]string{"time": strconv.FormatInt(t_ms(), 16), "Filename": fn, "Text": m, "error": err})
|
||||
json.NewEncoder(w).Encode(map[string]string{"time": strconv.FormatInt(getMsTimestamp(), 16), "Filename": fn, "Text": m, "error": err})
|
||||
}
|
||||
|
||||
func t_ms() (int64) {
|
||||
func getMsTimestamp() (int64) {
|
||||
now := time.Now()
|
||||
ns := now.UnixNano()
|
||||
ms := ns / 1000000
|
||||
|
@ -88,7 +87,6 @@ var m_prev = ""
|
|||
|
||||
func main() {
|
||||
uid := os.Getuid()
|
||||
t.Filename = ""
|
||||
|
||||
if (uid == -1) {
|
||||
fmt.Println("Windows is unsupported")
|
||||
|
@ -103,5 +101,5 @@ func main() {
|
|||
|
||||
fmt.Println("Serving " + prj + " " + version + " on " + server_inet6)
|
||||
http.ListenAndServe(server_inet6, nil)
|
||||
t.Cleanup()
|
||||
//t.Cleanup()
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue