- 在函数计算配置文件中新增 `redis_password` 字段。 - 更新 API 和 Worker 环境变量以传递 Redis 密码。 - 提升服务安全性,支持连接受保护的 Redis 实例。
102 lines
2.7 KiB
YAML
102 lines
2.7 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"
|
||
redis_password: "your-password"
|
||
|
||
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}
|
||
REDIS_PASSWORD: ${vars.redis_password}
|
||
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}
|
||
REDIS_PASSWORD: ${vars.redis_password}
|
||
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: "{}"
|