Skip to content

Commit

Permalink
Merge pull request #16 from simple-rules/ricl-loghost
Browse files Browse the repository at this point in the history
Ricl loghost
  • Loading branch information
lzl124631x authored Jun 30, 2018
2 parents c16dea1 + 27640fa commit 297d846
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 8 deletions.
49 changes: 49 additions & 0 deletions aws-code/loghost/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
package main

import (
"bufio"
"fmt"
"net"
"os"
)

const (
CONN_HOST = "localhost"
CONN_PORT = "3000"
CONN_TYPE = "tcp"
CONN_URL = CONN_HOST + ":" + CONN_PORT
)

func main() {
// Listen for incoming connections.
l, err := net.Listen(CONN_TYPE, CONN_URL)
if err != nil {
fmt.Println("Error listening:", err.Error())
os.Exit(1)
}
// Close the listener when the application closes.
defer l.Close()
fmt.Println("Listening on " + CONN_URL)
for {
// Listen for an incoming connection.
conn, err := l.Accept()
if err != nil {
fmt.Println("Error accepting: ", err.Error())
os.Exit(1)
}
// Handle connections in a new goroutine.
go handleRequest(conn)
}
}

// Handles incoming requests.
func handleRequest(conn net.Conn) {
for {
data, err := bufio.NewReader(conn).ReadString('\n')
if err != nil {
fmt.Println("Error reading:", err.Error())
break
}
fmt.Println(data)
}
}
8 changes: 4 additions & 4 deletions benchmark.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,10 @@ func main() {
// Setup a logger to stdout and log file.
logFileName := fmt.Sprintf("./%v/%v.log", *logFolder, *port)
h := log.MultiHandler(
log.Must.FileHandler(logFileName, log.LogfmtFormat()),
log.StdoutHandler)
// In cases where you just want a stdout logger, use the following one instead.
// h := log.CallerFileHandler(log.StdoutHandler)
log.StdoutHandler,
log.Must.FileHandler(logFileName, log.LogfmtFormat()), // Log to file
// log.Must.NetHandler("tcp", ":3000", log.JSONFormat()) // Log to remote
)
log.Root().SetHandler(h)

consensus := consensus.NewConsensus(*ip, *port, shardId, peers, leader)
Expand Down
8 changes: 4 additions & 4 deletions client/txgen/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -257,10 +257,10 @@ func main() {
// Setup a logger to stdout and log file.
logFileName := fmt.Sprintf("./%v/tx-generator.log", *logFolder)
h := log.MultiHandler(
log.Must.FileHandler(logFileName, log.LogfmtFormat()),
log.StdoutHandler)
// In cases where you just want a stdout logger, use the following one instead.
// h := log.CallerFileHandler(log.StdoutHandler)
log.StdoutHandler,
log.Must.FileHandler(logFileName, log.LogfmtFormat()), // Log to file
// log.Must.NetHandler("tcp", ":3000", log.JSONFormat()) // Log to remote
)
log.Root().SetHandler(h)

// Nodes containing utxopools to mirror the shards' data in the network
Expand Down

0 comments on commit 297d846

Please sign in to comment.