func main() { var settings Settings workers.ParseArgs(&settings) // Load the client cert cert, err := czmq.NewCertFromFile(settings.ClientCertificatePath) if err != nil { log.Error(err.Error()) os.Exit(1) } // Load the server cert server_cert, err := czmq.NewCertFromFile(settings.BrokerKeyPath) if err != nil { log.Error(err.Error()) os.Exit(1) } log.WithFields(log.Fields{"broker": settings.Broker, "service": service}).Info("Worker starting up") worker := mdp.NewJSONRPCWorker(settings.Broker, service) worker.CurveServerPublicKey = server_cert.PublicText() worker.CurveCertificate = cert worker.Register(&Pushover{client: settings.ClientKey, user: settings.UserKey}) worker.Run() }
func main() { var settings Settings _, err := flags.Parse(&settings) if err != nil { switch err.(*flags.Error).Type { case flags.ErrHelp: os.Exit(0) default: log.Error(err.Error()) os.Exit(1) } } broker_endpoint := "inproc://fancy-req" server_cert, err := czmq.NewCertFromFile(settings.ServerCertificatePath) if err != nil { log.Error(err.Error()) os.Exit(1) } agent, _ := zap.NewZapAgent() // TODO(sissel): Gate access to prevent untrusted connections. go agent.Run(zap.NewRestrictedAccess()) defer agent.Destroy() b, err := mdp.NewBroker(broker_endpoint) if err != nil { log.Fatalf("NewBroker(%s) failed: %s", broker_endpoint, err) } b.CurveCertificate = server_cert b.Bind("inproc://fancy-dealer") port, err := b.Bind("tcp://*:*") log.WithFields(log.Fields{"address": fmt.Sprintf("tcp://*:%d", port)}).Info("Broker available") go RunHTTP(":8111", "/zws/1.0") b.Run() }