-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
55 lines (40 loc) · 1.4 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
package main
import (
"cfs/config"
"cfs/corehandler/synchandler"
"flag"
"fmt"
"log"
"os"
"strconv"
)
func ConfigureLogger(minerId int) *os.File {
logfile, logFErr := os.Create("./storage/logs/log" + strconv.Itoa(minerId) + ".log")
if logFErr != nil {
log.Fatalf("Error opening log file: %v", logFErr)
}
log.SetOutput(logfile)
log.SetFlags(log.Llongfile | log.Ldate | log.Ltime) // Todo: add it later | log.LUTC
return logfile
}
func main() {
minerId := flag.Int("minerid", 2, "miner id")
flag.Parse()
logfile := ConfigureLogger(*minerId)
defer logfile.Close()
fmt.Println("miner: " + strconv.Itoa(*minerId))
config.NewSingletonConfigHandler(config.ConsoleArg{MinerId: *minerId})
// sharedchannel := sharedchannel.NewSingletonSharedChannel()
//Todo: remove once testing is done
// go func() {
// time.Sleep(time.Duration(cfslib.Random(1, 10)) * time.Minute)
// sharedchannel.InternalOperationChannel <- message.NewOperationMsg(entity.NewOperation("first.txt", modelconst.CREATE_FILE, nil), message.ADD)
// }()
// //Todo: remove once testing is done
// go func() {
// time.Sleep(time.Duration(cfslib.Random(10, 20)) * time.Minute)
// sharedchannel.InternalOperationChannel <- message.NewOperationMsg(entity.NewOperation("first.txt", modelconst.APPEND_RECORD, []byte("Append please")), message.ADD)
// }()
synchandler := synchandler.NewSingletonSyncHandler()
synchandler.Sync()
}