From 24044b65c68253130dfa937cc929f0dfa3a2576c Mon Sep 17 00:00:00 2001 From: s444501 Date: Thu, 12 Jan 2023 18:02:56 +0100 Subject: [PATCH] fixes2 --- main.py | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/main.py b/main.py index 0287714..311c8fd 100644 --- a/main.py +++ b/main.py @@ -4,7 +4,8 @@ from pathlib import Path from hcloud import Client from hcloud.images.domain import Image from hcloud.load_balancer_types.domain import LoadBalancerType -from hcloud.load_balancers.domain import LoadBalancerTarget, LoadBalancerService, LoadBalancerHealthCheck +from hcloud.load_balancers.domain import LoadBalancerTarget, LoadBalancerService, LoadBalancerHealthCheck, \ + LoadBalancerHealtCheckHttp from hcloud.locations.domain import Location from hcloud.networks.domain import NetworkSubnet from hcloud.server_types.domain import ServerType @@ -64,7 +65,19 @@ lb = client.load_balancers.create( protocol="http", listen_port=8080, destination_port=8080, - proxyprotocol=False + proxyprotocol=False, + health_check=LoadBalancerHealthCheck( + protocol="http", + port="8080", + interval=15, + timeout=10, + retries=3, + http=LoadBalancerHealtCheckHttp( + path="/factors/10", + status_codes=["2??", "3??"], + tls=False + ) + ), ) ], targets=lb_targets, @@ -75,5 +88,5 @@ lb = client.load_balancers.create( lb.action.wait_until_finished() print(f"Mechanizm równoważenia obciążenia został utworzony: {lb.action.complete}") - -print(f"Webserwis pod adresem http://{lb.load_balancer.data_model.public_net.ipv4.ip}:8080/factors/") +load_balancer = client.load_balancers.get_by_name(load_balancer_name) +print(f"Webserwis pod adresem http://{load_balancer.data_model.public_net.ipv4.ip}:8080/factors/")