-
Notifications
You must be signed in to change notification settings - Fork 0
/
knowledgecat.go
46 lines (40 loc) · 1.13 KB
/
knowledgecat.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
package main
import (
"flag"
"fmt"
"github.com/gorilla/mux"
"log"
"net/http"
"time"
)
// datadir and bindaddr are required runtime parameters.
var datadir *string
var bindaddr *string
var _ *string
var version *string
// init does basic initialization of the KnowledgeCat applications - establishes connection
// with databases, performs migrations if needed.
func init() {
fmt.Println("Booting KnowledgeCat...")
fmt.Println("")
datadir = flag.String("datadir", "data/", "Select location of data directory.")
bindaddr = flag.String("bindaddr", "0.0.0.0:8000", "Bind address (with port)")
_ = flag.String("configfile", "config.toml", "Location of configuration file")
}
// main() is main entrypoint for application.
func main() {
fmt.Println("KnowledgeCat 0.0.2-dev")
fmt.Println("==================\n\n")
fmt.Println("Data directory:", *datadir)
fmt.Println("Application will listen on:", *bindaddr)
r := mux.NewRouter()
generateRoutes(r)
http.Handle("/", r)
srv := &http.Server{
Handler: r,
Addr: *bindaddr,
WriteTimeout: 15 * time.Second,
ReadTimeout: 15 * time.Second,
}
log.Fatal(srv.ListenAndServe())
}