worker: Add env variable to change INFLUX, RNG and HASHER hosts
continuous-integration/drone/push Build is passing Details
continuous-integration/drone/tag Build is passing Details

This commit is contained in:
nemunaire 2021-11-19 12:16:18 +01:00
parent fa1ad86200
commit be67659532
1 changed files with 6 additions and 3 deletions

View File

@ -6,6 +6,9 @@ import time
from influxdb import InfluxDBClient
DEBUG = os.environ.get("DEBUG", "").lower().startswith("y")
INFLUXDB_HOST = os.environ.get("INFLUXDB_HOST", "influxdb")
RNG_HOST = os.environ.get("RNG_HOST", "rng")
HASHER_HOST = os.environ.get("HASHER_HOST", "hasher")
log = logging.getLogger(__name__)
if DEBUG:
@ -14,15 +17,15 @@ else:
logging.basicConfig(level=logging.INFO)
logging.getLogger("requests").setLevel(logging.WARNING)
client = InfluxDBClient('influxdb', 8086, os.environ.get("INFLUXDB_USER", "chocominer"), os.environ.get("INFLUXDB_USER_PASSWORD", "chocominer"), os.environ.get("INFLUXDB_DB", "chocominer"))
client = InfluxDBClient(INFLUXDB_HOST, 8086, os.environ.get("INFLUXDB_USER", "chocominer"), os.environ.get("INFLUXDB_USER_PASSWORD", "chocominer"), os.environ.get("INFLUXDB_DB", "chocominer"))
def get_random_bytes():
r = requests.get("http://rng/32")
r = requests.get("http://" + RNG_HOST + "/32")
return r.content
def hash_bytes(data):
r = requests.post("http://hasher/",
r = requests.post("http://" + HASHER_HOST + "/",
data=data,
headers={"Content-Type": "application/octet-stream"})
hex_hash = r.text