无服务器 WSGI 不在管道中工作(在本地工作)
Serverless WSGI not working in pipelines (works locally)
我在 bitbucket 管道中配置了以下步骤:
# Configure Serverless
- cp requirements.txt src/requirements.txt
- serverless config credentials --provider aws --key ${AWS_KEY} --secret ${AWS_SECRET}
- cd src
- sls plugin install -n serverless-python-requirements
- sls plugin install -n serverless-wsgi
- sls plugin install -n serverless-dotenv-plugin
# Perform the Deployment
- sls deploy --stage ${LOCAL_SERVERLESS_STAGE}
- sls deploy list functions
# Prep the environment
- sls wsgi manage --command "migrate"
- sls wsgi manage --command "collectstatic --noinput"
当管道 运行s 时,sls deploy
工作得很好,部署的功能完全按预期运行。然而,sls wsgi manage
命令抛出以下错误:
Serverless Error ----------------------------------------
Function "undefined" doesn't exist in this Service
Get Support --------------------------------------------
Docs: docs.serverless.com
Bugs: github.com/serverless/serverless/issues
Issues: forum.serverless.com
Your Environment Information ---------------------------
Operating System: linux
Node Version: 11.13.0
Framework Version: 2.35.0
Plugin Version: 4.5.3
SDK Version: 4.2.2
Components Version: 3.8.2
我可以在本地 运行 sls wsgi manage
命令(使用相同的 AWS 密钥)而没有问题。这个问题似乎只发生在管道中。
想法?
附加信息
serverless.yml
service: service-api
plugins:
- serverless-python-requirements
- serverless-wsgi
- serverless-dotenv-plugin
custom:
wsgi:
app: service.wsgi.application
packRequirements: false
pythonRequirements:
dockerFile: ./serverless-dockerfile
dockerizePip: non-linux
pythonBin: python3
useDownloadCache: false
useStaticCache: false
provider:
name: aws
runtime: python3.6
stage: dev
region: us-east-1
iamRoleStatements:
- Effect: "Allow"
Action:
- s3:GetObject
- s3:PutObject
Resource: "arn:aws:s3:::*"
# vpc:
# securityGroupIds:
# -
# subnetIds:
# -
# -
# -
# -
functions:
app:
handler: wsgi.handler
events:
- http: ANY /
- http: "ANY {proxy+}"
timeout: 600
无服务器部署列表函数的输出
+ sls deploy list functions
(node:1127) ExperimentalWarning: queueMicrotask() is experimental.
(node:1127) ExperimentalWarning: The fs.promises API is experimental
(node:1127) ExperimentalWarning: The dns.promises API is experimental
Serverless: Deprecation warning: Detected ".env" files. In the next major release variables from ".env" files will be automatically loaded into the serverless build process. Set "useDotenv: true" to adopt that behavior now.
More Info: https://www.serverless.com/framework/docs/deprecations/#LOAD_VARIABLES_FROM_ENV_FILES
Serverless: DOTENV: Loading environment variables from .env:
...STUFF HERE...
Serverless: Deprecation warning: CLI options definitions were upgraded with "type" property (which could be one of "string", "boolean", "multiple"). Below listed plugins do not predefine type for introduced options:
- ServerlessWSGI for "port", "host", "disable-threading", "num-processes", "ssl", "command", "file"
Please report this issue in plugin issue tracker.
Starting with next major release, this will be communicated with a thrown error.
More Info: https://www.serverless.com/framework/docs/deprecations/#CLI_OPTIONS_SCHEMA
Serverless: Configuration warning at 'functions.app.events[1].http': value 'ANY {proxy+}' does not satisfy pattern /^(?:\*|(GET|POST|PUT|PATCH|OPTIONS|HEAD|DELETE|ANY) (\/\S*))$/i
Serverless:
Serverless: Learn more about configuration validation here: http://slss.io/configuration-validation
Serverless:
Serverless: Deprecation warning: Starting with next major, Serverless will throw on configuration errors by default. Adapt to this behavior now by adding "configValidationMode: error" to service configuration
More Info: https://www.serverless.com/framework/docs/deprecations/#CONFIG_VALIDATION_MODE_DEFAULT
Serverless: Deprecation warning: Starting with version 3.0.0, following property will be replaced:
"provider.iamRoleStatements" -> "provider.iam.role.statements"
More Info: https://www.serverless.com/framework/docs/deprecations/#PROVIDER_IAM_SETTINGS
Serverless: Deprecation warning: Resolution of lambda version hashes was improved with better algorithm, which will be used in next major release.
Switch to it now by setting "provider.lambdaHashingVersion" to "20201221"
More Info: https://www.serverless.com/framework/docs/deprecations/#LAMBDA_HASHING_VERSION_V2
Serverless: Listing functions and their last 5 versions:
Serverless: -------------
Serverless: app: $LATEST, 1, 2, 3
答案很平凡。 Serverless 2.32+ 引入了一些破坏管道的变化。恢复到版本 2.31.0 解决了这个问题。
我在 bitbucket 管道中配置了以下步骤:
# Configure Serverless
- cp requirements.txt src/requirements.txt
- serverless config credentials --provider aws --key ${AWS_KEY} --secret ${AWS_SECRET}
- cd src
- sls plugin install -n serverless-python-requirements
- sls plugin install -n serverless-wsgi
- sls plugin install -n serverless-dotenv-plugin
# Perform the Deployment
- sls deploy --stage ${LOCAL_SERVERLESS_STAGE}
- sls deploy list functions
# Prep the environment
- sls wsgi manage --command "migrate"
- sls wsgi manage --command "collectstatic --noinput"
当管道 运行s 时,sls deploy
工作得很好,部署的功能完全按预期运行。然而,sls wsgi manage
命令抛出以下错误:
Serverless Error ----------------------------------------
Function "undefined" doesn't exist in this Service
Get Support --------------------------------------------
Docs: docs.serverless.com
Bugs: github.com/serverless/serverless/issues
Issues: forum.serverless.com
Your Environment Information ---------------------------
Operating System: linux
Node Version: 11.13.0
Framework Version: 2.35.0
Plugin Version: 4.5.3
SDK Version: 4.2.2
Components Version: 3.8.2
我可以在本地 运行 sls wsgi manage
命令(使用相同的 AWS 密钥)而没有问题。这个问题似乎只发生在管道中。
想法?
附加信息
serverless.yml
service: service-api
plugins:
- serverless-python-requirements
- serverless-wsgi
- serverless-dotenv-plugin
custom:
wsgi:
app: service.wsgi.application
packRequirements: false
pythonRequirements:
dockerFile: ./serverless-dockerfile
dockerizePip: non-linux
pythonBin: python3
useDownloadCache: false
useStaticCache: false
provider:
name: aws
runtime: python3.6
stage: dev
region: us-east-1
iamRoleStatements:
- Effect: "Allow"
Action:
- s3:GetObject
- s3:PutObject
Resource: "arn:aws:s3:::*"
# vpc:
# securityGroupIds:
# -
# subnetIds:
# -
# -
# -
# -
functions:
app:
handler: wsgi.handler
events:
- http: ANY /
- http: "ANY {proxy+}"
timeout: 600
无服务器部署列表函数的输出
+ sls deploy list functions
(node:1127) ExperimentalWarning: queueMicrotask() is experimental.
(node:1127) ExperimentalWarning: The fs.promises API is experimental
(node:1127) ExperimentalWarning: The dns.promises API is experimental
Serverless: Deprecation warning: Detected ".env" files. In the next major release variables from ".env" files will be automatically loaded into the serverless build process. Set "useDotenv: true" to adopt that behavior now.
More Info: https://www.serverless.com/framework/docs/deprecations/#LOAD_VARIABLES_FROM_ENV_FILES
Serverless: DOTENV: Loading environment variables from .env:
...STUFF HERE...
Serverless: Deprecation warning: CLI options definitions were upgraded with "type" property (which could be one of "string", "boolean", "multiple"). Below listed plugins do not predefine type for introduced options:
- ServerlessWSGI for "port", "host", "disable-threading", "num-processes", "ssl", "command", "file"
Please report this issue in plugin issue tracker.
Starting with next major release, this will be communicated with a thrown error.
More Info: https://www.serverless.com/framework/docs/deprecations/#CLI_OPTIONS_SCHEMA
Serverless: Configuration warning at 'functions.app.events[1].http': value 'ANY {proxy+}' does not satisfy pattern /^(?:\*|(GET|POST|PUT|PATCH|OPTIONS|HEAD|DELETE|ANY) (\/\S*))$/i
Serverless:
Serverless: Learn more about configuration validation here: http://slss.io/configuration-validation
Serverless:
Serverless: Deprecation warning: Starting with next major, Serverless will throw on configuration errors by default. Adapt to this behavior now by adding "configValidationMode: error" to service configuration
More Info: https://www.serverless.com/framework/docs/deprecations/#CONFIG_VALIDATION_MODE_DEFAULT
Serverless: Deprecation warning: Starting with version 3.0.0, following property will be replaced:
"provider.iamRoleStatements" -> "provider.iam.role.statements"
More Info: https://www.serverless.com/framework/docs/deprecations/#PROVIDER_IAM_SETTINGS
Serverless: Deprecation warning: Resolution of lambda version hashes was improved with better algorithm, which will be used in next major release.
Switch to it now by setting "provider.lambdaHashingVersion" to "20201221"
More Info: https://www.serverless.com/framework/docs/deprecations/#LAMBDA_HASHING_VERSION_V2
Serverless: Listing functions and their last 5 versions:
Serverless: -------------
Serverless: app: $LATEST, 1, 2, 3
答案很平凡。 Serverless 2.32+ 引入了一些破坏管道的变化。恢复到版本 2.31.0 解决了这个问题。