Use worker server
This commit is contained in:
16
main.go
16
main.go
@@ -4,6 +4,7 @@ import (
|
|||||||
"github.com/sevlyar/go-daemon"
|
"github.com/sevlyar/go-daemon"
|
||||||
"gitlab.com/saburly/kiviscraplib/structures"
|
"gitlab.com/saburly/kiviscraplib/structures"
|
||||||
"gitlab.com/saburly/kiviscraplib/webserver"
|
"gitlab.com/saburly/kiviscraplib/webserver"
|
||||||
|
"gitlab.com/saburly/kiviscraplib/workerserver"
|
||||||
"log"
|
"log"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -37,20 +38,9 @@ func main() {
|
|||||||
end = make(chan string)
|
end = make(chan string)
|
||||||
|
|
||||||
go webserver.ServeHTTP(queue, end)
|
go webserver.ServeHTTP(queue, end)
|
||||||
go func() {
|
go workerserver.ServeWorkers(queue, end)
|
||||||
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
|
|
||||||
}
|
|
||||||
}()
|
|
||||||
|
|
||||||
ended := <-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