git-svn-id: https://weed-fs.googlecode.com/svn/trunk@7 282b0af5-e82d-9cf1-ede4-77906d7719d0

This commit is contained in:
chris.lu@gmail.com
2011-12-13 00:17:36 +00:00
parent 2858701e6c
commit 5381479177
2 changed files with 31 additions and 19 deletions

View File

@@ -103,6 +103,11 @@ func dirJoinHandler(w http.ResponseWriter, r *http.Request) {
json.Unmarshal([]byte(r.FormValue("volumes")), volumes)
server.directory.Add(directory.NewMachine(s, publicServer), volumes)
}
func dirStatusHandler(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", "text/plain")
bytes, _ := json.Marshal(server.directory)
fmt.Fprint(w, bytes)
}
var server *Haystack
@@ -115,7 +120,7 @@ func main() {
}
server = new(Haystack)
if *chunkEnabled || bothEnabled {
log.Println("Chunk data stored in", *chunkFolder)
log.Println("data stored in", *chunkFolder)
server.store = store.NewStore(*chunkServer, *publicServer, *chunkFolder)
defer server.store.Close()
http.HandleFunc("/", storeHandler)
@@ -126,11 +131,12 @@ func main() {
http.HandleFunc("/dir/read", dirReadHandler)
http.HandleFunc("/dir/write", dirWriteHandler)
http.HandleFunc("/dir/join", dirJoinHandler)
http.HandleFunc("/dir/status", dirStatusHandler)
}
go func() {
time.Sleep(3000 * 1000)
server.store.Join(*metaServer)
log.Println("stored joined at", *metaServer)
log.Println("store joined at", *metaServer)
}()
log.Println("Serving at http://127.0.0.1:" + strconv.Itoa(*port))