-
-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix #15: Add basic support for expvar
- Loading branch information
1 parent
2b122a8
commit 32a89d2
Showing
4 changed files
with
52 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package main | ||
|
||
import ( | ||
_ "expvar" | ||
"fmt" | ||
"log" | ||
"net" | ||
"net/http" | ||
) | ||
|
||
// StartExpvarServer will start a small tcp server for the expvar package. | ||
// This server is only available via localhost on localhost:port/debug/vars | ||
func StartExpvarServer(port int) error { | ||
sock, err := net.Listen("tcp", fmt.Sprintf("localhost:%d", port)) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
go func() { | ||
log.Printf("Expvar initialisation success: HTTP now available at http://localhost:%d/debug/vars", port) | ||
http.Serve(sock, nil) | ||
}() | ||
|
||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters