deno.com
在此頁面上

在命令列上使用 deployctl

deployctl 是一個命令列工具 (CLI),讓您無需離開終端機即可操作 Deno Deploy 平台。有了它,您可以部署您的程式碼、建立和管理您的專案及其部署作業,並監控它們的使用情況和日誌。

相依性 跳到標題

deployctl 唯一的相依性是 Deno runtime。您可以執行以下命令來安裝它

curl -fsSL https://deno.land/install.sh | sh

您不需要事先設定 Deno Deploy 帳戶。它會在您部署第一個專案時一併建立。

安裝 deployctl 跳到標題

安裝 Deno runtime 後,您可以使用以下命令安裝 deployctl 工具

deno install -gArf jsr:@deno/deployctl

deno install 命令中的 -A 選項會授予已安裝腳本所有權限。您可以選擇不使用它,在這種情況下,系統會在工具執行期間需要時提示您授予必要的權限。

部署 跳到標題

若要執行程式碼的新部署作業,請導覽至專案的根目錄並執行

deployctl deploy

專案與進入點 跳到標題

如果這是專案的首次部署,deployctl 將根據它所在的 Git 儲存庫或目錄猜測專案名稱。同樣地,它會透過尋找具有常見進入點名稱 (main.ts、src/main.ts 等) 的檔案來猜測進入點。首次部署後,使用的設定將儲存在設定檔中 (預設為 deno.json)。

您可以使用 --project--entrypoint 引數分別指定專案名稱和/或進入點。如果專案不存在,將會自動建立。預設情況下,它會在使用者的個人組織中建立,但也可以透過指定 --org 引數在自訂組織中建立。如果組織尚不存在,也會自動建立。

deployctl deploy --project=helloworld --entrypoint=src/entrypoint.ts --org=my-team

包含與排除檔案 跳到標題

預設情況下,deployctl 會部署目前目錄中的所有檔案 (遞迴方式,node_modules 目錄除外)。您可以使用 --include--exclude 引數 (設定檔也支援) 自訂此行為。這些引數接受特定檔案、整個目錄和 glob。以下是一些範例

  • 僅包含來源和靜態檔案

    deployctl deploy --include=./src --include=./static
    
  • 僅包含 Typescript 檔案

    deployctl deploy --include=**/*.ts
    
  • 排除本機工具和產生物件

    deployctl deploy --exclude=./tools --exclude=./benches
    

一個常見的陷阱是不包含需要執行的原始碼模組 (進入點和相依性)。以下範例將會失敗,因為未包含 main.ts

deployctl deploy --include=./static --entrypoint=./main.ts

進入點也可以是遠端腳本。常見的使用案例是使用 std/http/file_server.ts 部署靜態網站 (更多詳細資訊請參閱 靜態網站教學)

deployctl deploy --include=dist --entrypoint=jsr:@std/http/file-server

環境變數 跳到標題

您可以使用 --env (設定個別環境變數) 或 --env-file (載入一個或多個環境檔案) 設定環境變數。這些選項可以組合並多次使用

deployctl deploy --env-file --env-file=.other-env --env=DEPLOYMENT_TS=$(date +%s)

部署作業將可以使用 Deno.env.get() 存取這些變數。請注意,使用 --env--env-file 設定的環境變數僅適用於正在建立的部署作業,並且不會新增至 為專案配置的環境變數 列表中。

生產環境部署 跳到標題

您建立的每個部署作業都有一個唯一的 URL。此外,專案具有「生產環境 URL」和自訂網域,可將流量路由到其「生產環境」部署作業。部署作業可以隨時升級為生產環境,或使用 --prod 旗標直接建立為生產環境。

deployctl deploy --prod

部署作業 文件中瞭解更多關於生產環境部署的資訊。

部署作業 跳到標題

deployments 子命令將所有關於部署作業的操作分組。

列表 跳到標題

您可以使用以下命令列出專案的部署作業

deployctl deployments list

輸出

✔ Page 1 of the list of deployments of the project 'my-project' is ready
┌───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
│  Deployment  │               Date               │   Status   │  Database  │                       Domain                       │ Entrypoint │  Branch  │  Commit  │
├───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤
│ kcbxc4xwe4mc │ 12/3/2024 13:21:40 CET (2 days)  │ Preview    │ Preview    │ https://my-project-kcbxc4xwe4mc.deno.dev │ main.ts    │ main     │ 4b6c506  │
│ c0ph5xa9exb3 │ 12/3/2024 13:21:25 CET (2 days)  │ Production │ Production │ https://my-project-c0ph5xa9exb3.deno.dev │ main.ts    │ main     │ 4b6c506  │
│ kwkbev9er4h2 │ 12/3/2024 13:21:12 CET (2 days)  │ Preview    │ Preview    │ https://my-project-kwkbev9er4h2.deno.dev │ main.ts    │ main     │ 4b6c506  │
│ dxseq0jc8402 │ 6/3/2024 23:16:51 CET (8 days)   │ Preview    │ Production │ https://my-project-dxseq0jc8402.deno.dev │ main.ts    │ main     │ 099359b  │
│ 7xr5thz8yjbz │ 6/3/2024 22:58:32 CET (8 days)   │ Preview    │ Preview    │ https://my-project-7xr5thz8yjbz.deno.dev │ main.ts    │ another  │ a4d2953  │
│ 4qr4h5ac3rfn │ 6/3/2024 22:57:05 CET (8 days)   │ Failed     │ Preview    │ n/a                                                │ main.ts    │ another  │ 56d2c88  │
│ 25wryhcqmb9q │ 6/3/2024 22:56:41 CET (8 days)   │ Preview    │ Preview    │ https://my-project-25wryhcqmb9q.deno.dev │ main.ts    │ another  │ 4b6c506  │
│ 64tbrn8jre9n │ 6/3/2024 8:21:33 CET (8 days)    │ Preview    │ Production │ https://my-project-64tbrn8jre9n.deno.dev │ main.ts    │ main     │ 4b6c506  │
│ hgqgccnmzg04 │ 6/3/2024 8:17:40 CET (8 days)    │ Failed     │ Production │ n/a                                                │ main.ts    │ main     │ 8071902  │
│ rxkh1w3g74e8 │ 6/3/2024 8:17:28 CET (8 days)    │ Failed     │ Production │ n/a                                                │ main.ts    │ main     │ b142a59  │
│ wx6cw9aya64c │ 6/3/2024 8:02:29 CET (8 days)    │ Preview    │ Production │ https://my-project-wx6cw9aya64c.deno.dev │ main.ts    │ main     │ b803784  │
│ a1qh5fmew2yf │ 5/3/2024 16:25:29 CET (9 days)   │ Preview    │ Production │ https://my-project-a1qh5fmew2yf.deno.dev │ main.ts    │ main     │ 4bb1f0f  │
│ w6pf4r0rrdkb │ 5/3/2024 16:07:35 CET (9 days)   │ Preview    │ Production │ https://my-project-w6pf4r0rrdkb.deno.dev │ main.ts    │ main     │ 6e487fc  │
│ nn700gexgdzq │ 5/3/2024 13:37:11 CET (9 days)   │ Preview    │ Production │ https://my-project-nn700gexgdzq.deno.dev │ main.ts    │ main     │ c5b1d1f  │
│ 98crfqxa6vvf │ 5/3/2024 13:33:52 CET (9 days)   │ Preview    │ Production │ https://my-project-98crfqxa6vvf.deno.dev │ main.ts    │ main     │ 090146e  │
│ xcdcs014yc5p │ 5/3/2024 13:30:58 CET (9 days)   │ Preview    │ Production │ https://my-project-xcdcs014yc5p.deno.dev │ main.ts    │ main     │ 5b78c0f  │
│ btw43kx89ws1 │ 5/3/2024 13:27:31 CET (9 days)   │ Preview    │ Production │ https://my-project-btw43kx89ws1.deno.dev │ main.ts    │ main     │ 663452a  │
│ 62tg1ketkjx7 │ 5/3/2024 13:27:03 CET (9 days)   │ Preview    │ Production │ https://my-project-62tg1ketkjx7.deno.dev │ main.ts    │ main     │ 24d1618  │
│ 07ag6pt6kjex │ 5/3/2024 13:19:11 CET (9 days)   │ Preview    │ Production │ https://my-project-07ag6pt6kjex.deno.dev │ main.ts    │ main     │ 4944545  │
│ 4msyne1rvwj1 │ 5/3/2024 13:17:16 CET (9 days)   │ Preview    │ Production │ https://my-project-4msyne1rvwj1.deno.dev │ main.ts    │ main     │ dda85e1  │
└───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
Press enter to fetch the next page [Enter]

此命令預設輸出 20 個部署作業的頁面。您可以使用 Enter 鍵迭代頁面,並使用 --page--limit 選項查詢特定頁面和頁面大小。

與其他命令一樣,如果您不在專案目錄中或想要列出來自不同專案的部署作業,您可以使用 --project 選項來指定要列出部署作業的專案。

顯示 跳到標題

使用以下命令取得特定部署作業的所有詳細資訊

deployctl deployments show

輸出

✔ The production deployment of the project 'my-project' is 'c0ph5xa9exb3'
✔ The details of the deployment 'c0ph5xa9exb3' are ready:

c0ph5xa9exb3
------------
Status:       Production
Date:         2 days, 12 hours, 29 minutes, 46 seconds ago (12/3/2024 13:21:25 CET)
Project:      my-project (e54f23b5-828d-4b7f-af12-706d4591062b)
Organization:	my-team (d97822ac-ee20-4ce9-b942-5389330b57ee)
Domain(s):    https://my-project.deno.dev
              https://my-project-c0ph5xa9exb3.deno.dev
Database:     Production (0efa985f-3793-48bc-8c05-f740ffab4ca0)
Entrypoint:   main.ts
Env Vars:     HOME
Git
  Ref:        main [4b6c506]
  Message:    change name
  Author:     John Doe @johndoe [mailto:johndoe@deno.com]
  Url:        https://github.com/arnauorriols/my-project/commit/4b6c50629ceeeb86601347732d01dc7ed63bf34f
Crons:        another cron [*/10 * * * *] succeeded at 15/3/2024 1:50:00 CET after 2 seconds (next at 15/3/2024 2:00:00 CET)
              newest cron [*/10 * * * *] n/a
              yet another cron [*/10 * * * *] failed at 15/3/2024 1:40:00 CET after 2 seconds (next at 15/3/2024 1:51:54 CET)

如果未指定部署作業,則命令會顯示專案目前生產環境部署作業的詳細資訊。若要查看上次部署作業的詳細資訊,請使用 --last,若要查看特定部署作業的詳細資訊,請使用 --id (或位置引數)。您也可以使用 --next--prev 依時間順序瀏覽部署作業。

例如,若要查看倒數第二次部署作業的詳細資訊,您可以執行

deployctl deployments show --last --prev

若要查看特定部署作業後 2 個部署作業的詳細資訊

deployctl deployments show 64tbrn8jre9n --next=2

重新部署 跳到標題

redeploy 命令會建立一個新的部署作業,重複使用現有部署作業的建置,目的是變更與其關聯的資源。這包括生產環境網域、環境變數和 KV 資料庫。

資訊

選取要重新部署的部署作業的語意與 show 子命令 的語意相同,包括 --last--id--next--prev

生產環境網域 跳到標題

如果您想要將專案的生產環境網域路由變更為特定部署作業,您可以使用 --prod 選項重新部署它

deployctl deployments redeploy --prod 64tbrn8jre9n

這將會使用與指定部署作業相同的程式碼和環境變數建立新的部署作業,但專案的生產環境網域會指向它。對於那些具有預覽/生產環境資料庫的專案 (即連結到 GitHub 的專案),這也會為新的部署作業設定生產環境資料庫。

注意

此功能類似於 Deno Deploy Web 應用程式中的「升級為生產環境」按鈕,但「升級為生產環境」按鈕不會建立新的部署作業。「升級為生產環境」按鈕會就地變更網域路由,但它僅限於已使用生產環境資料庫的部署作業。

KV 資料庫 跳到標題

如果是 GitHub 部署作業,它將會有 2 個資料庫,一個用於生產環境部署作業,另一個用於預覽部署作業。您可以使用 --db 選項重新部署部署作業來變更部署作業的資料庫

deployctl deployments redeploy --db=prod --id=64tbrn8jre9n

注意

當重新部署部署作業到生產環境時,預設情況下它會自動將其配置為使用生產環境資料庫。您可以組合使用 --prod--db 選項來選擇不使用此行為。例如,以下命令將重新部署目前的生產環境部署作業 (鑑於缺少位置引數、--id--last)。新的部署作業將成為新的生產環境部署作業,但它將使用預覽資料庫而不是生產環境資料庫

deployctl deployments redeploy --prod --db=preview

如果您的組織有自訂資料庫,您也可以透過 UUID 設定它們

deployctl deployments redeploy --last --db=5261e096-f9aa-4b72-8440-1c2b5b553def

環境變數 跳到標題

建立部署作業時,它會繼承專案的環境變數。鑑於部署作業是不可變的,因此永遠無法變更其環境變數。若要在部署作業中設定新的環境變數,您需要使用 --env (設定個別變數) 和 --env-file (載入一個或多個環境檔案) 重新部署它。

以下命令會使用 .env.other-env 檔案中定義的環境變數,以及設定為目前時間戳記的 DEPLOYMENT_TS 變數,重新部署目前的生產環境部署作業。產生的部署作業將會是預覽部署作業 (即生產環境網域不會將流量路由到它,因為缺少 --prod)。

deployctl deployments redeploy --env-file --env-file=.other-env --env=DEPLOYMENT_TS=$(date +%s)

注意

請注意,當變更環境變數時,只有在 redeploy 命令中設定的環境變數才會被新的部署作業使用。專案環境變數和正在重新部署的部署作業的環境變數將被忽略。如果這不符合您的需求,請在 https://github.com/denoland/deploy_feedback/issues/ 回報您的意見回饋

注意

當您在 Deno Deploy Web 應用程式中變更專案環境變數時,目前的生產環境部署作業會使用新的環境變數重新部署,而新的部署作業會成為新的生產環境部署作業。

刪除 跳到標題

您可以使用 delete 子命令刪除部署作業

deployctl deployments delete 64tbrn8jre9n

showredeploy 類似,delete 也可以使用 --last--next--prev 來選取要刪除的部署作業。以下是一個範例命令,可刪除專案的所有部署作業,但最後一個除外 (謹慎使用!)

while deployctl deployments delete --project=my-project --last --prev; do :; done

專案 跳到標題

projects 子命令將所有針對整個專案的操作分組。這包括 listshowrenamecreatedelete

列表 跳到標題

deployctl projects list 輸出您的使用者有權存取的所有專案,依組織分組

Personal org:
    blog
    url-shortener

'my-team' org:
    admin-site
    main-site
    analytics

您可以使用 --org 依組織篩選

deployctl projects list --org=my-team

顯示 跳到標題

若要查看特定專案的詳細資訊,請使用 projects show。如果您在專案內,它會從設定檔中擷取專案 ID。您也可以使用 --project 或位置引數指定專案

deployctl projects show main-site

輸出

main-site
---------
Organization:	my-team (5261e096-f9aa-4b72-8440-1c2b5b553def)
Domain(s):  	https://my-team.com
		          https://main-site.deno.dev
Dash URL:	    https://dash.deno.com/projects/8422c515-f68f-49b2-89f3-157f4b144611
Repository:	  https://github.com/my-team/main-site
Databases:  	[main] dd28e63e-f495-416b-909a-183380e3a232
		          [*] e061c76e-4445-409a-bc36-a1a9040c83b3
Crons:		    another cron [*/10 * * * *] succeeded at 12/3/2024 14:40:00 CET after 2 seconds (next at 12/3/2024 14:50:00 CET)
		          newest cron [*/10 * * * *] n/a
		          yet another cron [*/10 * * * *] failed at 12/3/2024 14:40:00 CET after 2 seconds (next at 12/3/2024 14:50:00 CET)
Deployments:	kcbxc4xwe4mc	c0ph5xa9exb3*	kwkbev9er4h2	dxseq0jc8402	7xr5thz8yjbz
		          4qr4h5ac3rfn	25wryhcqmb9q	64tbrn8jre9n	hgqgccnmzg04	rxkh1w3g74e8
		          wx6cw9aya64c	a1qh5fmew2yf	w6pf4r0rrdkb	nn700gexgdzq	98crfqxa6vvf
		          xcdcs014yc5p	btw43kx89ws1	62tg1ketkjx7	07ag6pt6kjex	4msyne1rvwj1

重新命名 跳到標題

可以使用 rename 子命令輕鬆重新命名專案。與其他命令類似,如果您從專案的目錄中執行命令,則不需要指定專案的目前名稱

deployctl projects rename my-personal-blog

輸出

ℹ Using config file '/private/tmp/blog/deno.json'
✔ Project 'blog' (8422c515-f68f-49b2-89f3-157f4b144611) found
✔ Project 'blog' renamed to 'my-personal-blog'

注意

請記住,專案的名稱是預覽網域 (https://my-personal-blog-kcbxc4xwe4mc.deno.dev) 和預設生產環境網域 (https://my-personal-blog.deno.dev) 的一部分。因此,當變更專案名稱時,具有先前名稱的 URL 將不再路由到專案的對應部署作業。

建立 跳到標題

您可以使用以下命令建立一個空的專案

deployctl projects create my-new-project

刪除 跳到標題

您可以使用以下命令刪除專案

deployctl projects delete my-new-project

頂端 跳到標題

top 子命令用於即時監控專案的資源使用情況

deployctl top

輸出

┌────────┬────────────────┬────────────────────────┬─────────┬───────┬─────────┬──────────┬─────────────┬────────────┬─────────┬─────────┬───────────┬───────────┐
│ (idx)  │ deployment     │ region                 │ Req/min │ CPU%  │ CPU/req │ RSS/5min │ Ingress/min │ Egress/min │ KVr/min │ KVw/min │ QSenq/min │ QSdeq/min │
├────────┼────────────────┼────────────────────────┼─────────┼───────┼─────────┼──────────┼─────────────┼────────────┼─────────┼─────────┼───────────┼───────────┤
│ 6b80e8 │ "kcbxc4xwe4mc" │ "asia-northeast1"      │      80 │ 0.61  │ 4.56    │ 165.908  │ 11.657      │ 490.847    │       0 │       0 │         0 │         0 │
│ 08312f │ "kcbxc4xwe4mc" │ "asia-northeast1"      │      76 │ 3.49  │ 27.58   │ 186.278  │ 19.041      │ 3195.288   │       0 │       0 │         0 │         0 │
│ 77c10b │ "kcbxc4xwe4mc" │ "asia-south1"          │      28 │ 0.13  │ 2.86    │ 166.806  │ 7.354       │ 111.478    │       0 │       0 │         0 │         0 │
│ 15e356 │ "kcbxc4xwe4mc" │ "asia-south1"          │      66 │ 0.97  │ 8.93    │ 162.288  │ 17.56       │ 4538.371   │       0 │       0 │         0 │         0 │
│ a06817 │ "kcbxc4xwe4mc" │ "asia-southeast1"      │     126 │ 0.44  │ 2.11    │ 140.087  │ 16.504      │ 968.794    │       0 │       0 │         0 │         0 │
│ d012b6 │ "kcbxc4xwe4mc" │ "asia-southeast1"      │     119 │ 2.32  │ 11.72   │ 193.704  │ 23.44       │ 8359.829   │       0 │       0 │         0 │         0 │
│ 7d9a3d │ "kcbxc4xwe4mc" │ "australia-southeast1" │       8 │ 0.97  │ 75      │ 158.872  │ 10.538      │ 3.027      │       0 │       0 │         0 │         0 │
│ 3c21be │ "kcbxc4xwe4mc" │ "australia-southeast1" │       1 │ 0.04  │ 90      │ 105.292  │ 0.08        │ 1.642      │       0 │       0 │         0 │         0 │
│ b75dc7 │ "kcbxc4xwe4mc" │ "europe-west2"         │     461 │ 5.43  │ 7.08    │ 200.573  │ 63.842      │ 9832.936   │       0 │       0 │         0 │         0 │
│ 33607e │ "kcbxc4xwe4mc" │ "europe-west2"         │      35 │ 0.21  │ 3.69    │ 141.98   │ 9.438       │ 275.788    │       0 │       0 │         0 │         0 │
│ 9be3d2 │ "kcbxc4xwe4mc" │ "europe-west2"         │     132 │ 0.92  │ 4.19    │ 180.654  │ 15.959      │ 820.513    │       0 │       0 │         0 │         0 │
│ 33a859 │ "kcbxc4xwe4mc" │ "europe-west3"         │    1335 │ 7.57  │ 3.4     │ 172.032  │ 178.064     │ 10967.918  │       0 │       0 │         0 │         0 │
│ 3f54ce │ "kcbxc4xwe4mc" │ "europe-west4"         │     683 │ 4.76  │ 4.19    │ 187.802  │ 74.696      │ 7565.017   │       0 │       0 │         0 │         0 │
│ cf881c │ "kcbxc4xwe4mc" │ "europe-west4"         │     743 │ 3.95  │ 3.19    │ 177.213  │ 86.974      │ 6087.454   │       0 │       0 │         0 │         0 │
│ b4565b │ "kcbxc4xwe4mc" │ "me-west1"             │       3 │ 0.21  │ 55      │ 155.46   │ 2.181       │ 0.622      │       0 │       0 │         0 │         0 │
│ b97970 │ "kcbxc4xwe4mc" │ "southamerica-east1"   │       3 │ 0.08  │ 25      │ 186.049  │ 1.938       │ 0.555      │       0 │       0 │         0 │         0 │
│ fd7a08 │ "kcbxc4xwe4mc" │ "us-east4"             │       3 │ 0.32  │ 80      │ 201.101  │ 0.975       │ 58.495     │       0 │       0 │         0 │         0 │
│ 95d68a │ "kcbxc4xwe4mc" │ "us-east4"             │     133 │ 1.05  │ 4.77    │ 166.052  │ 28.107      │ 651.737    │       0 │       0 │         0 │         0 │
│ c473e7 │ "kcbxc4xwe4mc" │ "us-east4"             │       0 │ 0     │ 0       │ 174.154  │ 0.021       │ 0          │       0 │       0 │         0 │         0 │
│ ebabfb │ "kcbxc4xwe4mc" │ "us-east4"             │      19 │ 0.15  │ 4.78    │ 115.732  │ 7.764       │ 67.054     │       0 │       0 │         0 │         0 │
│ eac700 │ "kcbxc4xwe4mc" │ "us-south1"            │     114 │ 2.37  │ 12.54   │ 183.001  │ 18.401      │ 22417.397  │       0 │       0 │         0 │         0 │
│ cd2194 │ "kcbxc4xwe4mc" │ "us-south1"            │      35 │ 0.33  │ 5.68    │ 145.871  │ 8.142       │ 91.236     │       0 │       0 │         0 │         0 │
│ 140fec │ "kcbxc4xwe4mc" │ "us-west2"             │     110 │ 1.43  │ 7.84    │ 115.298  │ 18.093      │ 977.993    │       0 │       0 │         0 │         0 │
│ 51689f │ "kcbxc4xwe4mc" │ "us-west2"             │    1105 │ 7.66  │ 4.16    │ 187.277  │ 154.876     │ 14648.383  │       0 │       0 │         0 │         0 │
│ c5806e │ "kcbxc4xwe4mc" │ "us-west2"             │     620 │ 4.38  │ 4.24    │ 192.291  │ 109.086     │ 9685.688   │       0 │       0 │         0 │         0 │
└────────┴────────────────┴────────────────────────┴─────────┴───────┴─────────┴──────────┴─────────────┴────────────┴─────────┴─────────┴───────────┴───────────┘
⠼ Streaming...

欄定義如下

描述
idx 執行個體鑑別器。用於區分在同一區域中執行的不同執行的不透明 ID。
deployment 在執行個體中執行的部署作業的 ID。
Req/min 專案每分鐘收到的請求數。
CPU% 專案使用的 CPU 百分比。
CPU/req 每個請求的 CPU 時間,以毫秒為單位。
RSS/5min 專案在過去 5 分鐘內使用的最大 RSS,以 MB 為單位。
Ingress/min 專案每分鐘接收的資料量,以 KB 為單位。
Egress/min 專案每分鐘輸出的資料量,以 KB 為單位。
KVr/min 專案每分鐘執行的 KV 讀取次數。
KVw/min 專案每分鐘執行的 KV 寫入次數。
QSenq/min 專案每分鐘執行的佇列入隊次數。
QSdeq/min 專案每分鐘執行的佇列出隊次數。

您可以使用 --region 依區域篩選,它接受子字串並且可以多次使用

deployctl top --region=asia --region=southamerica

日誌 跳到標題

您可以使用 deployctl logs 擷取部署作業的日誌。它同時支援將日誌串流到主控台的即時日誌,以及查詢擷取過去產生的日誌的持久化日誌。

若要顯示專案目前生產環境部署作業的即時日誌

deployctl logs

注意

與 Deno Deploy Web 應用程式不同,目前當生產環境部署作業變更時,logs 子命令不會自動切換到新的生產環境部署作業。

若要顯示特定部署作業的即時日誌

deployctl logs --deployment=1234567890ab

可以使用 --levels--regions--grep 選項依層級、區域和文字篩選日誌

deployctl logs --levels=error,info --regions=region1,region2 --grep='unexpected'

若要顯示持久化日誌,請使用 --since 和/或 --until 選項

deployctl logs --since=$(date -Iseconds -v-2H) --until=$(date -Iseconds -v-30M)
deployctl logs --since=$(date -Iseconds --date='2 hours ago') --until=$(date -Iseconds --date='30 minutes ago')

API 跳到標題

如果您使用 子託管 APIdeployctl api 將協助您透過處理驗證和標頭與 API 互動

deployctl api /projects/my-personal-blog/deployments

使用 --method--body 指定 HTTP 方法和請求主體

deployctl api --method=POST --body='{"name": "main-site"}' organizations/5261e096-f9aa-4b72-8440-1c2b5b553def/projects

本機開發 跳到標題

對於本機開發,您可以使用 deno CLI。若要安裝 deno,請依照 Deno 手冊 中的指示操作。

安裝後,您可以在本機執行您的腳本

$ deno run --allow-net=:8000 ./main.ts
Listening on https://127.0.0.1:8000

若要監看檔案變更,請新增 --watch 旗標

$ deno run --allow-net=:8000 --watch ./main.ts
Listening on https://127.0.0.1:8000

如需更多關於 Deno CLI 以及如何配置您的開發環境和 IDE 的資訊,請造訪 Deno 手冊的 開始使用 章節。

JSON 輸出 跳到標題

所有輸出資料的命令都有 --format=json 選項,可將資料以 JSON 物件輸出。當 stdout 不是 TTY 時,特別是在管道傳輸到另一個命令時,此輸出模式為預設模式。結合 jq,此模式可以程式化方式使用 deployctl 提供的所有資料

取得目前生產環境部署作業的 ID

deployctl deployments show | jq .build.deploymentId

取得每個區域每個隔離區 CPU 時間/請求的 csv 串流

deployctl top | jq -r '[.id,.region,.cpuTimePerRequest] | @csv'

您找到需要的資訊了嗎?

隱私權政策