Load server config and use config values instead of hardcoded values

This commit is contained in:
Bilal
2020-05-08 10:46:18 +02:00
parent 2d1f226ab7
commit 89dbcf0d9f
4 changed files with 18 additions and 1 deletions

1
.gitignore vendored
View File

@@ -1,3 +1,4 @@
*.log
*.pid
.env

View File

@@ -1,3 +1,7 @@
# kiviscrapbalancer
Kivi scraping load balancer
Kivi scraping load balancer
## Setup
Copy `example.env` to the `.env` and set desired values

9
example.env Normal file
View File

@@ -0,0 +1,9 @@
# Check default values in kiviscraplib/config/config.go
WEB_SERVER_ADDRESS = Address in form of IP:PORT (127.0.0.1:1337) on which web server will listen for scrap requests
WEB_SERVER_API_KEY = API key that needs to be present in scrap request
WEB_SERVER_TIMEOUT = Number of seconds to wait for worker client before timeout-ing scrap requests
WORKER_SERVER_ADDRESS = Address in form of IP:PORT (127.0.0.1:1338) on which worker server will listen for worker clients
WORKER_SERVER_WORKERS_COUNT = Number of possible worker clients
WORKER_SERVER_REQUEST_MESSAGE_PREFIX = Prefix to prepend on the request message when sending to the worker client. Use double quotes if prefix has a space (eg. "URL ")

View File

@@ -2,6 +2,7 @@ package main
import (
"github.com/sevlyar/go-daemon"
"gitlab.com/saburly/kiviscraplib/config"
"gitlab.com/saburly/kiviscraplib/structures"
"gitlab.com/saburly/kiviscraplib/webserver"
"gitlab.com/saburly/kiviscraplib/workerserver"
@@ -14,6 +15,8 @@ var end chan string
// To terminate the daemon use:
// kill `cat sample.pid`
func main() {
config.InitServerConfig()
cntxt := &daemon.Context{
PidFileName: "sample.pid",
PidFilePerm: 0644,