netdata_tsrelay.nim
changeset 6 1f366fc61592
parent 5 a1276c3d39eb
child 7 c0bcf3bea772
equal deleted inserted replaced
5:a1276c3d39eb 6:1f366fc61592
   198     ## Open a database connection, bind to the listening socket,
   198     ## Open a database connection, bind to the listening socket,
   199     ## and start serving incoming netdata streams.
   199     ## and start serving incoming netdata streams.
   200     let db = open( "", "", "", conf.dbopts )
   200     let db = open( "", "", "", conf.dbopts )
   201     if conf.verbose: echo( "Successfully connected to the backend database.".hl( fgGreen ) )
   201     if conf.verbose: echo( "Successfully connected to the backend database.".hl( fgGreen ) )
   202 
   202 
   203     var
   203     var server = newSocket()
   204         server = newSocket()
       
   205         client = newSocket()
       
   206 
   204 
   207     server.set_sock_opt( OptReuseAddr, true )
   205     server.set_sock_opt( OptReuseAddr, true )
   208     server.bind_addr( Port(conf.listen_port), conf.listen_addr )
   206     server.bind_addr( Port(conf.listen_port), conf.listen_addr )
   209     server.listen()
   207     server.listen()
   210 
   208 
   216             hl( $conf.listen_port, fgBlue, bright=true ),
   214             hl( $conf.listen_port, fgBlue, bright=true ),
   217         )
   215         )
   218         echo ""
   216         echo ""
   219 
   217 
   220     while true:
   218     while true:
       
   219         var client  = newSocket()
   221         var address = ""
   220         var address = ""
       
   221 
       
   222         client.close
   222         server.acceptAddr( client, address ) # blocking call
   223         server.acceptAddr( client, address ) # blocking call
   223         spawn runthread( client, address, db, conf )
   224         spawn runthread( client, address, db, conf )
   224 
   225 
   225 
   226 
   226 proc atexit() {.noconv.} =
   227 proc atexit() {.noconv.} =