Vapor 大型教程
部署到 Vapor Cloud
Vapor Cloud 的部署流程可以压缩成几个命令,但失败后怎么取消、资源怎么清理同样重要。这里记录 deploy、查看状态和清理资源的操作。
部署
$ vapor cloud deploy
app: TILApp
git: https://github.com/wangzhizhou/TILApp-BackEnd.git
env: production
db: yes
replicas: 1
replica size: free
branch: master
build: incremental
Creating deployment [Done]
Connecting to build logs ...
Waiting in Queue [Done]
Checkout branch 'master' [Done]
Verifying base folder [Done]
Selected swift version: 4.1.0 [Done]
Building vapor (release) [Done]
Trying to find executable [Done]
Found executable: Run [Done]
Creating container registry [Done]
Building container [Done]
Pushing container to registry [Done]
Updating replicas [Done]
Deployment succeeded: https://joker.vapor.cloud [Done]
Successfully deployed.
取消部署并删除
首先需要把部署的机器数变为 0:
$ vapor cloud deploy --replicas=0
然后在 Vapor 云上自己的帐号中,从内到外一级一级删除。
上线前检查
- 把数据库连接、密钥和第三方凭证放在平台环境变量中,不要写进 Git 仓库。
- 确认生产环境使用 release 构建,并通过健康检查接口验证进程、数据库和迁移均已完成。
- 部署完成后检查域名、HTTPS、日志和回滚方式,再把副本数从测试配置调整到业务需要的数量。
版本提示:这里记录的是 Vapor Cloud 旧版命令输出。云平台命令和套餐可能发生变化,实际部署前请以当前官方 CLI 帮助和控制台文档为准。