Samuel Barbosa
11/29/2023, 1:09 PMversion: "3.9"
services:
prefect:
image: prefecthq/prefect:2.10.21-python3.11
container_name: prefect-server
restart: unless-stopped
volumes:
- prefect:/root/.prefect
entrypoint:
[
"/opt/prefect/entrypoint.sh",
"prefect",
"server",
"start"
]
environment:
- PREFECT_API_URL=<http://my-ip:4300/api>
- PREFECT_UI_URL=<http://my-ip:4300/api>
- PREFECT_SERVER_API_HOST=0.0.0.0
- PREFECT_SERVER_API_PORT=4300
- PYTHONIOENCODING=utf-8
ports:
- 4300:4300
volumes:
prefect:
networks:
default:
name: prefect-network
Then, in another machine, I set PREFECT_API_URL="http://my-ip:4300/api" and try the following deployment:
from prefect import flow
from pleg_flows.tasks.reunioes import atualiza_reunioes_pleg
from prefect.deployments import Deployment
from datetime import date, timedelta
hoje = date.today()
data_ref = hoje - timedelta(days=5)
last_month = (hoje - timedelta(days=30)).strftime("%Y%m%d")
@flow(name="MongoDB PLEG", log_prints=True)
def fluxo_pleg():
atualiza_reunioes_pleg(params={"ini": last_month}, last_update=data_ref)
if __name__ == "__main__":
fluxo_pleg.serve(name="Atualiza Reunioes PLEG", cron="0 6 * * 1,2,3,4,5")
When I execute the script, I get error 502 (bad gateway). But I can go to http://my-ip:4300/dashboard and it works fine.
What am I missing?Marvin
11/29/2023, 1:11 PMPREFECT_API_URL
environment variable is set correctly in your script. It should match the PREFECT_API_URL
in your docker-compose file.
3. Server Health: Check the health of your Prefect server. You can do this by checking the logs of your Prefect server. If there's an issue with the server, it should show up in the logs.
4. Firewall or Security Group Settings: Sometimes, firewall or security group settings can prevent one machine from accessing another. Check to see if there's a rule that might be blocking the connection.
5. Prefect Version Compatibility: Ensure that the Prefect version you're using in your script is compatible with the Prefect server version. You're using Prefect version 2.10.21 in your docker-compose file. Make sure you're using a compatible version in your script.
If none of these suggestions work, you might want to consider reaching out to the Prefect community or support for more specific help.Netanel Malka
02/22/2024, 10:55 AM