Skip to content

Prefect のインストール (Salyut)

現在 http://salyut.labs.basisconsulting.co.jp:4200/ にて運用している Prefect Server のインストールメモを以下に書く予定:

Prefect のインストール

TODO

Prefect パッケージのインストール

pip install prefect

Postgresql のインストール (Docker)

docker run -d --name prefect-postgres -v prefectdb:/var/lib/postgresql/data -p 127.0.0.1:5432:5432 -e POSTGRES_USER=postgres -e POSTGRES_PASSWORD=postgres -e POSTGRES_DB=prefect postgres:14.1-alpine
docker run prefect-postgres

Prefect のDBサーバーを Postgresql へ向ける

prefect config set PREFECT_API_DATABASE_CONNECTION_URL="postgresql+asyncpg://postgres:postgres@localhost:5432/prefect"

Prefect その他初期設定

prefect config set PREFECT_API_URL="http://salyut.labs.basisconsulting.co.jp:4200/api"

Prefectの設定確認

prefect config view

結果:

PREFECT_PROFILE='default'
PREFECT_API_DATABASE_CONNECTION_URL='********' (from profile)
PREFECT_API_URL='http://salyut.labs.basisconsulting.co.jp:4200/api' (from profile)

Nginx 等のリバースプロキシで 0.0.0.0:4200 へのアクセスを 127.0.0.1:4200 へ向ける

WebSocketを使ってるので proxy_set_header をきちんと設定する

server {
        listen 203.180.239.83:4200 default_server;
        listen [::]:4200 default_server;
        proxy_set_header    Host    $host;
        proxy_set_header    X-Real-IP    $remote_addr;
        proxy_set_header    X-Forwarded-Host       $host;
        proxy_set_header    X-Forwarded-Server    $host;
        proxy_set_header    X-Forwarded-For    $proxy_add_x_forwarded_for;

        location / {
                proxy_pass    http://localhost:4200/;
        }
}