func (s *Server) ConnectToLogger() { return if s.Logger == "" || s.Hostname == "" || s.App == "" { dbg.Lvl4("skipping connect to logger") return } dbg.Lvl4("Connecting to Logger") lh, _ := logutils.NewLoggerHook(s.Logger, s.Hostname, s.App) dbg.Lvl4("Connected to Logger") log.AddHook(lh) }
func main() { deter, err := deploy.ReadConfig() if err != nil { log.Fatal("Couldn't load config-file in forkexec:", err) } conf = deter.Config dbg.DebugVisible = conf.Debug flag.Parse() // connect with the logging server if logger != "" { // blocks until we can connect to the logger lh, err := logutils.NewLoggerHook(logger, physaddr, conf.App) if err != nil { log.WithFields(log.Fields{ "file": logutils.File(), }).Fatalln("Error setting up logging server:", err) } log.AddHook(lh) } setup_deter() i := 0 var wg sync.WaitGroup virts := physToServer[physaddr] if len(virts) > 0 { dbg.Lvl3("starting timestampers for", len(virts), "client(s)", virts) i = (i + 1) % len(loggerports) for _, name := range virts { dbg.Lvl4("Starting", name, "on", physaddr) wg.Add(1) go func(nameport string) { dbg.Lvl3("Running on", physaddr, "starting", nameport) defer wg.Done() args := []string{ "-hostname=" + nameport, "-logger=" + logger, "-physaddr=" + physaddr, "-amroot=" + strconv.FormatBool(nameport == rootname), "-test_connect=" + strconv.FormatBool(testConnect), "-mode=server", "-app=" + conf.App, } dbg.Lvl3("Starting on", physaddr, "with args", args) cmdApp := exec.Command("./app", args...) //cmd.Stdout = log.StandardLogger().Writer() //cmd.Stderr = log.StandardLogger().Writer() cmdApp.Stdout = os.Stdout cmdApp.Stderr = os.Stderr dbg.Lvl3("fork-exec is running command:", args) err = cmdApp.Run() if err != nil { dbg.Lvl2("cmd run:", err) } // get CPU usage stats st := cmdApp.ProcessState.SystemTime() ut := cmdApp.ProcessState.UserTime() log.WithFields(log.Fields{ "file": logutils.File(), "type": "forkexec", "systime": st, "usertime": ut, }).Info("") dbg.Lvl2("Finished with Timestamper", physaddr) }(name) } dbg.Lvl3(physaddr, "Finished starting timestampers") wg.Wait() } else { dbg.Lvl2("No timestampers for", physaddr) } dbg.Lvl2(physaddr, "timestampers exited") }
func main() { deter, err := deploy.ReadConfig() if err != nil { log.Fatal("Couldn't load config-file in exec") } conf = deter.Config dbg.DebugVisible = conf.Debug flag.Parse() dbg.Lvl3("Running", appConf.App, appConf.Hostname, "with logger at", appConf.Logger) defer func() { log.Errorln("Terminating host", appConf.Hostname) }() // connect with the logging server if appConf.Logger != "" && (appConf.AmRoot || conf.Debug > 0) { // blocks until we can connect to the appConf.Logger dbg.Lvl3(appConf.Hostname, "Connecting to Logger") lh, err := logutils.NewLoggerHook(appConf.Logger, appConf.Hostname, conf.App) if err != nil { log.WithFields(log.Fields{ "file": logutils.File(), }).Fatalln("Error setting up logging server:", err) } log.AddHook(lh) //log.SetOutput(ioutil.Discard) //fmt.Println("exiting appConf.Logger block") dbg.Lvl4(appConf.Hostname, "Done setting up hook") } if appConf.Mode == "server" { if appConf.PhysAddr == "" { h, _, err := net.SplitHostPort(appConf.Hostname) if err != nil { log.Fatal(appConf.Hostname, "improperly formatted hostname", os.Args) } appConf.PhysAddr = h } // run an http server to serve the cpu and memory profiles go func() { _, port, err := net.SplitHostPort(appConf.Hostname) if err != nil { log.Fatal(appConf.Hostname, "improperly formatted hostname: should be host:port") } p, _ := strconv.Atoi(port) // uncomment if more fine grained memory debuggin is needed //runtime.MemProfileRate = 1 dbg.Lvl3(http.ListenAndServe(net.JoinHostPort(appConf.PhysAddr, strconv.Itoa(p+2)), nil)) }() } dbg.Lvl3("Running timestamp with rFail and fFail: ", conf.RFail, conf.FFail) switch appConf.App { case "coll_sign": coll_sign.Run(&appConf, conf) case "coll_stamp": coll_stamp.Run(&appConf, conf) case "schnorr_sign": schnorr_sign.Run(&appConf, conf) } }