worker: Add env variable to change INFLUX, RNG and HASHER hosts
This commit is contained in:
parent
fa1ad86200
commit
be67659532
@ -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
|
||||
|
Reference in New Issue
Block a user