-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
62 lines (46 loc) · 1.17 KB
/
main.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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
package main
import (
"flag"
_ "github.com/microsoft/go-mssqldb"
"log"
"main/src/chatanalize"
"main/src/description"
"main/src/searchsn"
"net/http"
_ "net/http/pprof"
"os"
"path/filepath"
"strconv"
"strings"
)
var (
port *int
)
func init() {
//port = 8431
port = flag.Int("p", 8431, "Port service")
}
func main() {
logfilename := filepath.Join("", "servicedescription.log")
logFile, err := os.OpenFile(logfilename, os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0644)
log.SetOutput(logFile)
log.SetFlags(log.LstdFlags | log.Lshortfile)
if err != nil {
log.Fatal(err)
}
defer func() {
_ = logFile.Close()
}()
//println("Help comandline arguments run: \n\tservicedescription -p PORT")
flag.Parse()
strport := strconv.Itoa(*port)
text, _ := description.ReadLines(filepath.Join("src", "welcome.txt"))
log.Printf(strings.Join(text, "\n"), strport)
mux := http.NewServeMux()
mux.HandleFunc("/description", description.ShowDescription)
mux.HandleFunc("/writedesription", description.WriteDescription)
mux.HandleFunc("/search", searchsn.Searchsn)
mux.HandleFunc("/chatanalize", chatanalize.Chatanalize)
err = http.ListenAndServe(":"+strport, mux)
log.Fatal(err)
}