You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

60 lines
1.3 KiB
Go

package main
import (
"fmt"
"os"
"flag"
"log"
"strconv"
2 years ago
"FRMS/internal/pkg/reactor"
"FRMS/internal/pkg/logging"
)
2 years ago
type coordinator interface {
Start()
}
func NewCoordinator(ip string,port int,ch chan error) coordinator {
2 years ago
// allows interface checking as opposed to calling directly
return reactor.NewCoordinator(ip,port,ch)
2 years ago
}
2 years ago
func main() {
var ip string
var port int
flag.Usage = func() {
w := flag.CommandLine.Output()
fmt.Fprintf(w, "Usage: %s port \n",os.Args[0])
}
iptr := flag.String("i","192.168.100.2","ip address of server")
//iptr := flag.String("i","192.1.168.136","ip address of laptop")
flag.Parse()
if flag.NArg() != 1 {
flag.Usage()
os.Exit(1)
}
args := flag.Args()
if p, err := strconv.Atoi(args[0]);p < 1024 || p > 65535 {
flag.Usage()
log.Fatal("Port must be between [1023,65535]")
} else if err != nil {
log.Fatal(err)
}
ip = *iptr
port, err := strconv.Atoi(args[0])
if err != nil {
log.Fatal(err)
}
2 years ago
ch := make(chan error)
rlc := NewCoordinator(ip,port,ch) // host port
2 years ago
go rlc.Start()
logging.Debug(logging.DStart, "Reactor Started")
err = <-ch
2 years ago
if err != nil {
log.Fatal(err)
}
}