-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.go
38 lines (31 loc) · 819 Bytes
/
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
package main
import (
"flag"
"log"
"net/http"
"os"
"github.com/wm/jas/lib"
)
func main() {
port := flag.String("port", "2468", "port to listen on")
logFile := flag.String("log", "./log/server.log", "log file")
flag.Parse()
setLog(logFile)
j := jas.NewJas()
j.RegisterHandlerFunc(jas.PushPayloadLogger)
j.RegisterHandler(jas.NewFileChangeEmailer(jas.FileChangeEmailerOptions{
Emails: &[]string{"will@example.com", "eliot@example.com"},
Files: &[]string{"db/structure.sql", "db/schema.rb"},
}))
mux := http.NewServeMux()
mux.Handle("/", j)
http.ListenAndServe(":"+*port, mux)
}
func setLog(logFile *string) {
log_handler, err := os.OpenFile(*logFile, os.O_APPEND|os.O_WRONLY|os.O_CREATE, 0777)
if err != nil {
panic("cannot write to log")
}
log.SetOutput(log_handler)
log.SetFlags(5)
}