Skip to content

Commit 62874ee

Browse files
committed
make the listening port configurable
1 parent f4e47cf commit 62874ee

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

main.go

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package main
22

33
import (
4+
"flag"
45
"log"
56
"net/http"
67
"os"
@@ -11,7 +12,17 @@ import (
1112
"github.com/rs/xlog"
1213
)
1314

15+
var (
16+
port string
17+
)
18+
19+
func init() {
20+
const defaultPort = "8080"
21+
flag.StringVar(&port, "p", defaultPort, "the port to listen on")
22+
}
23+
1424
func main() {
25+
flag.Parse()
1526
var err error
1627
db, err := newBoltStore()
1728
if err != nil {
@@ -54,5 +65,5 @@ func main() {
5465

5566
r.FileServer("/", http.Dir("./dashboard/"))
5667

57-
log.Fatal(http.ListenAndServe(":8080", r))
68+
log.Fatal(http.ListenAndServe(":"+port, r))
5869
}

0 commit comments

Comments
 (0)