Hi all, new Prefect user here. I've managed to se...
# ask-community
s
Hi all, new Prefect user here. I've managed to set up a simple deployment and can get it running as a dev instance using SQLite. Now I'm trying to run it under supervisord and connect to a Postgresql server. No matter what I do I can't get the server to start successfully under supervisord. I have a simple bash script that sets up the env and runs the server. I have an
apps
user that is used to run all apps on this server.
Copy code
web-server-01:/var/log/apps# cat /opt/apps/fpga-automation/start_prefect.sh
#!/bin/bash
source /opt/apps/fpga-automation/venv/bin/activate
export PREFECT_API_DATABASE_CONNECTION_URL="<postgresql+asyncpg://prefect_user:prefectdb@10.10.8.114:5432/prefect_automation>"
export PREFECT_HOME="/opt/apps/prefect"
export HOME="/home/apps"
export PREFECT_LOGGING_LEVEL=DEBUG
exec prefect server start --host 127.0.0.1 --port 4200
And the error looks like a DNS failure?
Copy code
___ ___ ___ ___ ___ ___ _____
| _ \ _ \ __| __| __/ __|_   _|
|  _/   / _|| _|| _| (__  | |
|_| |_|_\___|_| |___\___| |_|

Configure Prefect to communicate with the server with:

    prefect config set PREFECT_API_URL=<http://127.0.0.1:4200/api>

View the API reference documentation at <http://127.0.0.1:4200/docs>

Check out the dashboard at <http://127.0.0.1:4200>



20:13:29.728 | ERROR   | prefect.server.utilities.postgres_listener - Failed to establish raw asyncpg connection for LISTEN/NOTIFY: [Errno -2] Name does not resolve
Traceback (most recent call last):
  File "/opt/apps/fpga-automation/venv/lib/python3.12/site-packages/prefect/server/utilities/postgres_listener.py", line 71, in get_pg_notify_connection
    conn = await asyncpg.connect(**connect_args)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/apps/fpga-automation/venv/lib/python3.12/site-packages/asyncpg/connection.py", line 2421, in connect
    return await connect_utils._connect(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/apps/fpga-automation/venv/lib/python3.12/site-packages/asyncpg/connect_utils.py", line 1075, in _connect
    raise last_error or exceptions.TargetServerAttributeNotMatched(
  File "/opt/apps/fpga-automation/venv/lib/python3.12/site-packages/asyncpg/connect_utils.py", line 1049, in _connect
    conn = await _connect_addr(
           ^^^^^^^^^^^^^^^^^^^^
  File "/opt/apps/fpga-automation/venv/lib/python3.12/site-packages/asyncpg/connect_utils.py", line 886, in _connect_addr
    return await __connect_addr(params, True, *args)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/apps/fpga-automation/venv/lib/python3.12/site-packages/asyncpg/connect_utils.py", line 931, in __connect_addr
    tr, pr = await connector
             ^^^^^^^^^^^^^^^
  File "/opt/apps/fpga-automation/venv/lib/python3.12/site-packages/asyncpg/connect_utils.py", line 802, in _create_ssl_connection
    tr, pr = await loop.create_connection(
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "uvloop/loop.pyx", line 1982, in create_connection
socket.gaierror: [Errno -2] Name does not resolve
If I run the script as root or the apps user it works fine. What am I missing?
n
hi @Shareef Jalloq - looks a db connection issue
if you run as root, perhaps your env var is properly set?
s
Ergh, this was a user error not reloading supervisor the correct way. It sorta works but not quite. All is well now. thanks.
n
catjam
s
Actually, that wasn't my issue. It seems that the errors I posted sometimes didn't get emitted so I thought I had fixed them. There were a few issues. For some reason, DNS doesn't work inside supervisord environments so swapping the DNS name for the IP address of my postgres server got rid of those. And then I was missing
PREFECT_API_URL
which also threw up and issue. But it looks like I just need to debug my deployments now.