变更内容: - 重构函数计算配置文件,移除旧版 aliyun-fc.yaml,新增符合 FC 3.0 标准的 s.yaml。 - 引入 Serverless Devs 工具支持,添加部署、验证、日志查看等命令指引。 - 调整 API 和 Worker 函数配置,支持更灵活的资源分配及自动化管理。 - 更新文档,提供 FC 3.0 部署指南及优化建议。
99 lines
2.5 KiB
YAML
99 lines
2.5 KiB
YAML
# 阿里云函数计算 FC 3.0 配置
|
||
# 使用 Serverless Devs 部署: cd deployment/serverless && s deploy
|
||
edition: 3.0.0
|
||
name: functional-scaffold
|
||
access: default
|
||
|
||
vars:
|
||
region: cn-hangzhou
|
||
image: registry.cn-hangzhou.aliyuncs.com/your-namespace/functional-scaffold:latest
|
||
redis_host: r-xxxxx.redis.rds.aliyuncs.com
|
||
redis_port: "6379"
|
||
|
||
resources:
|
||
# API 服务函数
|
||
prime-checker-api:
|
||
component: fc3
|
||
props:
|
||
region: ${vars.region}
|
||
functionName: prime-checker-api
|
||
description: 质数判断算法服务(API)
|
||
runtime: custom-container
|
||
cpu: 0.35
|
||
memorySize: 512
|
||
diskSize: 512
|
||
timeout: 60
|
||
instanceConcurrency: 10
|
||
handler: not-used
|
||
customContainerConfig:
|
||
image: ${vars.image}
|
||
port: 8000
|
||
command:
|
||
- /app/entrypoint.sh
|
||
healthCheckConfig:
|
||
httpGetUrl: /healthz
|
||
initialDelaySeconds: 3
|
||
periodSeconds: 5
|
||
timeoutSeconds: 3
|
||
failureThreshold: 3
|
||
successThreshold: 1
|
||
environmentVariables:
|
||
APP_ENV: production
|
||
LOG_LEVEL: INFO
|
||
METRICS_ENABLED: "true"
|
||
RUN_MODE: api
|
||
REDIS_HOST: ${vars.redis_host}
|
||
REDIS_PORT: ${vars.redis_port}
|
||
vpcConfig: auto
|
||
logConfig: auto
|
||
triggers:
|
||
- triggerName: http-trigger
|
||
triggerType: http
|
||
triggerConfig:
|
||
authType: anonymous
|
||
methods:
|
||
- GET
|
||
- POST
|
||
- PUT
|
||
- DELETE
|
||
|
||
# 异步任务 Worker 函数
|
||
job-worker:
|
||
component: fc3
|
||
props:
|
||
region: ${vars.region}
|
||
functionName: job-worker
|
||
description: 异步任务 Worker
|
||
runtime: custom-container
|
||
cpu: 0.35
|
||
memorySize: 512
|
||
diskSize: 512
|
||
timeout: 900
|
||
instanceConcurrency: 1
|
||
handler: not-used
|
||
customContainerConfig:
|
||
image: ${vars.image}
|
||
port: 8000
|
||
command:
|
||
- /app/entrypoint.sh
|
||
environmentVariables:
|
||
APP_ENV: production
|
||
LOG_LEVEL: INFO
|
||
METRICS_ENABLED: "true"
|
||
RUN_MODE: worker
|
||
REDIS_HOST: ${vars.redis_host}
|
||
REDIS_PORT: ${vars.redis_port}
|
||
WORKER_POLL_INTERVAL: "1.0"
|
||
MAX_CONCURRENT_JOBS: "5"
|
||
JOB_MAX_RETRIES: "3"
|
||
JOB_EXECUTION_TIMEOUT: "300"
|
||
vpcConfig: auto
|
||
logConfig: auto
|
||
triggers:
|
||
- triggerName: timer-trigger
|
||
triggerType: timer
|
||
triggerConfig:
|
||
cronExpression: "0 */1 * * * *"
|
||
enable: true
|
||
payload: "{}"
|