-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.go
More file actions
55 lines (44 loc) · 1.22 KB
/
main.go
File metadata and controls
55 lines (44 loc) · 1.22 KB
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
package main
import (
"fis/socket/content"
"fis/socket/ibis"
"fis/socket/socket"
fissync "fis/socket/sync"
"fmt"
"log"
"net/http"
"github.com/joho/godotenv"
)
func init() {
// loads values from .env into the system
if err := godotenv.Load(); err != nil {
log.Print("No .env file found")
}
}
func main() {
log.Println("General:\tsocket process started")
go func() {
fmt.Println("FileServer:\tStarting file server")
// http.ListenAndServe(":8080", http.FileServer(http.Dir("static")))
http.ListenAndServe(":8080", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Access-Control-Allow-Origin", "*")
http.FileServer(http.Dir("static")).ServeHTTP(w, r)
}))
}()
// start socket server
server := socket.StartSocket()
// channel for database sync messages
dbSync := make(chan bool, 1)
// start sync service
sync := fissync.CreateSynchronizer(dbSync)
sync.StartBackgroundSync()
// create ibis controller
go func() {
fmt.Println("IbisService:\tcreating ibis controller")
ibis.CreateController(server)
}()
// create media controller
fmt.Println("SequenceController:\tcreating media controller")
content.CreateController(server, dbSync)
fmt.Println("socket process ended")
}