# HG changeset patch # User Atul Varma # Date 1245957643 25200 # Node ID a98e6a1144a96d0169c5360e58a5f3d01c96a868 # Parent c0d5fa0d3b9f303dead293ecb62d875301ec8c30 Added some basic help info to the memory profiling server. diff -r c0d5fa0d3b9f -r a98e6a1144a9 memory_profiler_server.js --- a/memory_profiler_server.js Thu Jun 25 12:13:22 2009 -0700 +++ b/memory_profiler_server.js Thu Jun 25 12:20:43 2009 -0700 @@ -3,9 +3,19 @@ var socket = new ServerSocket(); +var IP = "127.0.0.1"; var PORT = 8080; +var BASE_URL = "http://" + IP + ":" + PORT; +var HELP = [ + "REST API methods available:", + "", + " /gc-roots JSON array of GC root object IDs.", + " /objects/{ID} JSON metadata about the given object ID.", + " /stop Stops the server."]; -socket.bind("127.0.0.1", PORT); +HELP = HELP.join("\r\n"); + +socket.bind(IP, PORT); socket.listen(); var NEWLINE = "\r\n"; @@ -23,7 +33,8 @@ } } -print("Waiting for requests on port " + PORT + "."); +print("Waiting for requests at " + BASE_URL + ".\n"); +print(HELP); function processRequest(socket) { var conn = socket.accept(); @@ -45,6 +56,9 @@ // but Firefox doesn't let us browse a webserver this way, which is // annoying, so we're just leaving it at text/plain for now. + if (path == "/") + toSend = HELP; + if (path == "/gc-roots") toSend = JSON.stringify(getGCRoots());