---
title: "Te wāhanga ipurangi i ngā Cloudflare Workers"
description: "Whakatū tētahi wāhanga ipurangi Quire kua whakaiti i ngā Cloudflare Workers."
image: "https://docs.quirelms.com/og.png"
---

> Documentation Index
> Fetch the complete documentation index at: https://docs.quirelms.com/mi/llms.txt
> Use this file to discover all available pages before exploring further.

# Te wāhanga ipurangi i ngā Cloudflare Workers

<span id="the-web-tier-on-cloudflare-workers"></span>

Ko te hoahoa te `docs/architecture/23-ops.md` wāhanga 6. Ka mahi ngā Workers i
tētahi wāhanga ipurangi kua whakaiti. Kāore kei tōna rohe te ōrite āheinga i ngā
Workers (PRD wāhanga 12): ka āraihia i te wā tīmata, me te kī ia ingoa, te mea
kāore e taea ana e tēnei wāhi.

## Te tū i tēnei whakaputanga <!--quire:status-in-this-release-->

Kua tū te whakarite (`apps/web/wrangler.jsonc`, te tūtohu `cloudflare-module` o
te Nitro, te hono Hyperdrive me ngā tātaritanga tīmata). Ka hiahiatia e tētahi
Worker te kohinga whakarite S3 mō te R2 (`QUIRE_STORAGE_DRIVER=s3`), tētahi
kaiwhakarato tūturu i waenga i ngā tono (`QUIRE_REALTIME_DRIVER=durable_objects`
rānei `centrifugo`), tētahi kohinga tohono (`QUIRE_CACHE_DRIVER=postgres` rānei
`valkey`) me tētahi kaiwhakarato īmēra HTTP. Me te kore ēnei, ka ārai te Worker
te tīmata, ā, ka kīia i tana rārangi pūrongo ia tautuhinga. Ko te kaiwhakarato
Durable Objects tētahi kaihoko o te Worker tūturu i te `apps/realtime-worker`
(tētahi Durable Object ia ara mō te tukunga, te noho tūmatanui me te whakapapa,
tētahi ia tāngata mō ngā wehenga); whakaturia ia i te taha, i te āhua raro,
rānei whakamahia te Centrifugo.

## Ngā wāhanga <!--quire:the-pieces-->

| Wāhanga | I te Cloudflare |
| --- | --- |
| `web` | Tētahi Worker me te `nodejs_compat` |
| Postgres | O waho, e tae ana ma te Hyperdrive: te `HYPERDRIVE` mō te tūwāhi taupānga, te `REPORT_HYPERDRIVE` mō te tūwāhi pūrongo i tētahi pūtaka ā-tinana. Ka tārua te wāhanga ipurangi ia hono kōrero ki te `DATABASE_URL` me te `QUIRE_REPORT_DATABASE_URL` i te wā tīmata |
| Ngā kōnae | R2, ma tana API S3 (`S3_ENDPOINT=https://<account>.r2.cloudflarestorage.com`); ka hono te tohu `FILES` ki te pākete |
| Ngā mahi i muri | pg-boss ma te Hyperdrive i te wā me tukuhia te mahi me tētahi tuhi. Me te `QUIRE_QUEUE_DRIVER=cloudflare` i te kai mahi tautoko, ka haere ngā mahi māmā (ngā whakamōhiotanga me ngā tuku webhook kāore e whakarārangihia) i te wāhi o ngā Cloudflare Queues, nō reira kāore e tono tukutahi ana te Postgres mō ēnei. Ka mahi te kai mahi tautoko i ērua |
| Tūturu | Te Worker tūturu, te `apps/realtime-worker`, me ngā Durable Objects |
| `worker`, `scheduler`, `collab`, `content`, ClamAV, Gotenberg, ffmpeg | Tētahi ipupā kaiwāhi tautoko. Kāore e taea e tētahi Worker te mahi i a rātou |
| Te mātātai | Te aroturuki Worker, e whakawāhia ana i te `wrangler.jsonc` |

Ka tuku te `REPORT_HYPERDRIVE` i te tūwāhi pūrongo mō te pūtaka ā-tinana e kīia
ana e te `HYPERDRIVE`. Kāore e tuku tēnei wāhi i ngā wāhanga e pūmau ana ki ētahi
atu pūtaka ā-tinana, i te āhua e ārahitia ana i raro.

## Te mea kāore e taea ana <!--quire:what-this-target-cannot-do-->

Ka āraihia i te wā tīmata, me te tuhia ia raruraru i te wā kotahi:

- **Kāore he SMTP.** Whakamahia tētahi kaiwhakarato HTTP i te
  `QUIRE_EMAIL_PROVIDER_CONFIG`.
- **Kāore he papa ā-rohe.** Me kī te `QUIRE_STORAGE_DRIVER` i tētahi kohinga
  āhuatanga.
- **Kāore he tūturu rānei kohinga i roto i te pū.** Ka kore e tohono ngā Workers
  i tētahi mahi mātā i waenga i ngā tono, nō reira ka āraihia te
  `QUIRE_REALTIME_DRIVER=inprocess` me te `QUIRE_CACHE_DRIVER=memory`.
- **Kāore he ClamAV, Gotenberg rānei ffmpeg i te Worker.** Ka āraihia ngā
  `CLAMAV_URL`, `GOTENBERG_URL` me te `FFMPEG_PATH` e tautuhia ana i te Worker;
  tautuhia rātou i te kai mahi tautoko.
- **Kāore he rōpū pūtaka motuhake.** Ka tautuhia ngā hono Hyperdrive o tētahi
  Worker i te wā whakaturanga, nō reira ka whiwhi tētahi rōpū me tōna ake pūtaka
  tētahi whārangi mārama "unavailable here". Whakatematema ia mai i te Compose
  rānei i te Vercel.

Ā, tētahi mea kāore e āraihia engari me mōhio: **kāore e mahi i ngā Workers te
whakaahua i mua me te whakahou tūturu ā-tikitiki**, ahakoa te āhua e kōrerotia
ana e te tuhinga tohutohu o te whakaraupapa. Ka whakaahua ia ara ia tono.

I tēnei wāhi pupuritia ngā whakawhitinga poto, ā, kāore e pupuria ia ā-wāhanga i
te karanga kupenga: ka whakatika anō te Hyperdrive i te tū hono i te wā ka hoki
te hono ki te pūtuki, nō reira ka tautuhia te horopaki wāhanga ia whakawhitinga.

## Te whakaturanga <!--quire:deploying-->

1. Hangaia ngā rauemi:
   ```sh
   bun run --bun wrangler hyperdrive create quire-app --connection-string="postgres://quire_app:...@db.example.com:5432/quire"
   bun run --bun wrangler hyperdrive create quire-report --connection-string="postgres://quire_report:...@db.example.com:5432/quire"
   bun run --bun wrangler r2 bucket create quire-files
   bun run --bun wrangler queues create quire-jobs
   ```
   Ka tautuhia ngā id Hyperdrive e rua i te `apps/web/wrangler.jsonc`.
2. Tautuhia ngā kupu tūmataiti, tētahi ā-wāhanga ma te
   `bun run --bun wrangler secret put <NAME>` mai i te `apps/web`: `QUIRE_SECRET_KEY`,
   `QUIRE_MASTER_KEY`, `QUIRE_EMAIL_PROVIDER_CONFIG`, `S3_ACCESS_KEY_ID`,
   `S3_SECRET_ACCESS_KEY`, `QUIRE_COLLAB_SIGNING_KEY`,
   `QUIRE_REALTIME_WORKER_SECRET`. Ngā tautuhinga kāore tūmataiti
   (`QUIRE_APP_ORIGIN`, `QUIRE_CONTENT_ORIGIN`, `QUIRE_PLATFORM_DOMAINS`,
   `QUIRE_DATABASE_ID`, `S3_ENDPOINT`, `S3_BUCKET`, `QUIRE_COLLAB_URL`) ka tukuna
   ki te `vars`.
3. Hanga whakaturia mai i te `apps/web`:
   ```sh
   NITRO_PRESET=cloudflare-module bun run build
   bun run --bun wrangler deploy
   ```
4. Whakaturia te Worker tūturu, me te `QUIRE_REALTIME_WORKER_SECRET` o te
   wāhanga ipurangi me tana kupu tūmataiti tohu hei `QUIRE_REALTIME_TOKEN_SECRET`
   (ka tā te wāhanga ipurangi ngā tohu tūturu me tana ake
   `QUIRE_REALTIME_TOKEN_SECRET`, rānei me te `QUIRE_SECRET_KEY` mēnā kāore e
   tautuhia, nō reira whakamahia tētahi e whakamahia ana e ia), ā, tautuhia te
   `QUIRE_REALTIME_WORKER_URL` i te wāhanga ipurangi ki tōna wāhi:
   ```sh
   cd apps/realtime-worker
   bun run --bun wrangler secret put QUIRE_REALTIME_WORKER_SECRET
   bun run --bun wrangler secret put QUIRE_REALTIME_TOKEN_SECRET
   bun run --bun wrangler deploy
   ```
5. Mō ngā mahi māmā i ngā Cloudflare Queues, hanga tētahi rārangi mō ia mahi
   māmā, ā, tautuhia ēnei i te kai mahi tautoko (tētahi tohu API e āea ana te
   pānui me te tuhi i ngā Queues):
   ```sh
   bun run --bun wrangler queues create quire-events-notifications
   bun run --bun wrangler queues create quire-events-notifications-dead
   bun run --bun wrangler queues create quire-events-webhooks
   bun run --bun wrangler queues create quire-events-webhooks-dead
   ```
   `QUIRE_QUEUE_DRIVER=cloudflare`, `CLOUDFLARE_ACCOUNT_ID`,
   `CLOUDFLARE_QUEUES_TOKEN`, me te `QUIRE_QUEUE_PREFIX` mēnā kāore te `quire-`.
6. Whakatematema te pūrere tautoko i te āhua i te [aratohu Vercel](/mi/ops/vercel/),
   kaupapa 3. Ka tū ngā whakawhiti i reira, i mua i ia whakaturanga Worker.

Ka whakaatuhia tētahi whakarite kāore e tāria i te `bun run --bun wrangler tail` ma te
"The web tier did not start on cloudflare", i muri i a ia ia tautuhinga hurihia.

Source: https://docs.quirelms.com/mi/ops/cloudflare/index.mdx
