2.0 KiB
kiviscrapbalancer
Kivi scraping load balancer
Setup
Copy example.env to the .env and set desired values
Deployment procedure
-
Compile source code with
go build -
Transfer generated binary to the Kivi load balancer server
Command for sending files to the remote computer :
scp -i path/to/the/key.pem path/to/the/binary username@host:/path/to/destinationPath on the server where load balancer resides is :
/home/ubuntu/kivi_scraper/load_balancer -
Add
.envfile next to the binary on the server and set correct valuesNote: for listening addresses, use
:1337and:1338or other ports but in this format, so the server can be reached from outsideNote : make sure firewalls(on the server and one from the platform where server is hosted) is not blocking selected ports
-
If
monitis not installed on the server, install it (sudo apt install monit) -
Create
starth.shwith contents#!/bin/sh cd /home/ubuntu/kivi_scraper/load_balancer ./kiviscrapbalancer -
Create
stop.shwith contents#!/bin/sh cd /home/ubuntu/kivi_scraper/load_balancer sudo kill `cat sample.pid` -
Edit
monitconfiguration withsudo nano /etc/monit/monitrc -
Around line 208 is example how to set process check. Add new line below example
-
Add to the file :
check process kivi_load_balancer with pidfile /home/ubuntu/kivi_scraper/load_balancer/sample.pid start program = "/home/ubuntu/kivi_scraper/load_balancer/start.sh" stop program = "/home/ubuntu/kivi_scraper/load_balancer/stop.sh" if failed port 1337 protocol http then restart if failed port 1338 then restart if 5 restarts within 5 cycles then timeout -
Reboot with
sudo reboot
Notes
-
To check
monitlogs, check/var/log/monit.log -
To check on which ports system is listening, use
sudo lsof -i -P -n | grep LISTEN