Load server config and use config values instead of hardcoded values
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -1,3 +1,4 @@
|
||||
*.log
|
||||
*.pid
|
||||
|
||||
.env
|
||||
@@ -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
9
example.env
Normal 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 ")
|
||||
3
main.go
3
main.go
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user