-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.go
More file actions
39 lines (34 loc) · 816 Bytes
/
main.go
File metadata and controls
39 lines (34 loc) · 816 Bytes
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
package main
import (
"fmt"
"os"
"os/signal"
"strconv"
"syscall"
ses "github.com/nddat1811/SES-algorithm/SES"
"github.com/nddat1811/SES-algorithm/network"
)
func registerExitSignal() {
c := make(chan os.Signal, 1)
signal.Notify(c, syscall.SIGINT, syscall.SIGTERM, os.Interrupt)
go func() {
<-c
os.Exit(1)
}()
}
func main() {
numberProcess, _ := strconv.Atoi(os.Args[1])
instanceID, _ := strconv.Atoi(os.Args[2])
registerExitSignal()
//fmt.Println("Number Process: ", numberProcess)
fmt.Println("process: ", instanceID)
ses.InitLog(instanceID, numberProcess)
network := network.NewNetwork(instanceID, numberProcess)
defer func() {
if r := recover(); r != nil {
network.SafetyClose()
}
}()
network.StartSending()
network.StartListening()
}