OLD | NEW |
1 // Application that serves up the contents of /tmp/glog via HTTP, giving access | 1 // Application that serves up the contents of /tmp/glog via HTTP, giving access |
2 // to logs w/o needing to SSH into the server. | 2 // to logs w/o needing to SSH into the server. |
3 package main | 3 package main |
4 | 4 |
5 import ( | 5 import ( |
6 "flag" | 6 "flag" |
7 "fmt" | 7 "fmt" |
8 "html/template" | 8 "html/template" |
9 "net/http" | 9 "net/http" |
10 "net/url" | 10 "net/url" |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
102 glog.Infof("Dir List: %s", name) | 102 glog.Infof("Dir List: %s", name) |
103 dirList(w, f) | 103 dirList(w, f) |
104 return | 104 return |
105 } | 105 } |
106 | 106 |
107 http.ServeContent(w, r, d.Name(), d.ModTime(), f) | 107 http.ServeContent(w, r, d.Name(), d.ModTime(), f) |
108 } | 108 } |
109 | 109 |
110 func main() { | 110 func main() { |
111 flag.Parse() | 111 flag.Parse() |
| 112 defer glog.Flush() |
112 | 113 |
113 if err := os.MkdirAll(*dir, 0777); err != nil { | 114 if err := os.MkdirAll(*dir, 0777); err != nil { |
114 glog.Fatalf("Failed to create dir for log files: %s", err) | 115 glog.Fatalf("Failed to create dir for log files: %s", err) |
115 } | 116 } |
116 | 117 |
117 flags.Log() | 118 flags.Log() |
118 | 119 |
119 http.Handle("/", http.StripPrefix("/", FileServer(http.Dir(*dir)))) | 120 http.Handle("/", http.StripPrefix("/", FileServer(http.Dir(*dir)))) |
120 glog.Fatal(http.ListenAndServe(*port, nil)) | 121 glog.Fatal(http.ListenAndServe(*port, nil)) |
121 } | 122 } |
OLD | NEW |