Use worker server
This commit is contained in:
16
main.go
16
main.go
@@ -4,6 +4,7 @@ import (
|
||||
"github.com/sevlyar/go-daemon"
|
||||
"gitlab.com/saburly/kiviscraplib/structures"
|
||||
"gitlab.com/saburly/kiviscraplib/webserver"
|
||||
"gitlab.com/saburly/kiviscraplib/workerserver"
|
||||
"log"
|
||||
)
|
||||
|
||||
@@ -37,20 +38,9 @@ func main() {
|
||||
end = make(chan string)
|
||||
|
||||
go webserver.ServeHTTP(queue, end)
|
||||
go func() {
|
||||
for {
|
||||
request := <-queue
|
||||
//time.Sleep(2 * time.Second)
|
||||
response := structures.Response{
|
||||
Url: request.Url,
|
||||
Content: []byte("<html><body><h1>Bla!</h1></body><html>"),
|
||||
Err: nil,
|
||||
}
|
||||
request.Response <- response
|
||||
}
|
||||
}()
|
||||
go workerserver.ServeWorkers(queue, end)
|
||||
|
||||
ended := <-end
|
||||
|
||||
log.Printf("%s ended so closing the daemon", ended)
|
||||
log.Printf("%s ended so closing the daemon\n", ended)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user