This topic describes common issues when using Serverless Devs and their solutions.
Configure the s.yaml file
For more information about YAML specifications, see YAML specifications.
Handle exceptions without error messages
To troubleshoot the issue, perform the following steps:
-
Run the
npm install @serverless-devs/s3 -gcommand to upgrade the tool. -
Run the
s clean --allcommand to delete all components and redundant files. -
Run
s -vto check the tool version.If the command returns no response, there may be an issue with your local Node.js environment. Reinstall Node.js 14 or a later version.
If the issue persists, join the DingTalk user group (Group ID: 64970014484), provide the log file and the s.yaml file, and contact a Function Compute engineer for help.
To find the log file, see the log path in the error log sample below.
✗ [hello_world] failed to [deploy]:
====================
Error Message:
InvalidArgument: code: 400, ContainerMemory is set to an invalid value. The value must be a multiple of 64 MB. (actual: '129') request id: 1-6552ec5e-8a5ca7458a55ec97d71589b8
Env: @serverless-devs/s3: 0.0.15-beta.4, darwin-x64 node-v16.16.0
Logs: /Users/sxxx/.s/logs/1114114116
Get Help: DingTalk: 33947367
Feedback: https://github.com/Serverless-Devs/Serverless-Devs/issues
Function not found in the console after deployment
If you cannot find the function in the console after the s deploy command finishes, try the following methods:
-
Search for your deployed function using a prefix match. Some projects create multiple functions. You can edit the
s.yamlfile to give allfunctionNamevalues in the project a common prefix, making them easier to find. -
Click the
icon to refresh the function list.
If you want to use Serverless Application Center to manage Serverless Devs projects, you can commit the project to a remote repository after you run the s init command, and then import the application in Serverless Application Center. For more information, see Manage applications. After the application is imported, the pipeline automatically deploys the project whenever you commit changes to the repository. You no longer need to run the s deploy command to deploy the project manually.
Handle configuration conflicts
-
If the local configuration in the
s.yamlfile conflicts with the online configuration, Serverless Devs prompts you to choose whether to deploy the project by using the local configuration. You can choose to use the local configuration or retain the online configuration.description: Serverless Devs Web Framework Function Modified => Serverless Devs Web Framework Function * You can also specify to use local configuration through --assume-yes/-y during deployment ? Deploy it with local config? (Y/n) Y -
To use the local configuration by default, add the
-yoption, for example,s deploy -y.
Multi-region deployment
Yes. For more information, see the following examples.
Shell script
#!/bin/bash
regions=("cn-hangzhou" "ap-southeast-1")
for r in ${regions[@]}
do
export REGION=$r
s deploy -y
done
s.yaml example
edition: 3.0.0
name: hello-world-app
access: "default"
resources:
hello_world:
component: fc3
props:
region: ${env('REGION')}
functionName: "start-nodejs-im1g"
description: 'hello world by serverless devs'
runtime: "nodejs14"
code: ./code
handler: index.handler
memorySize: 128
timeout: 30
Local debugging
-
If your function uses a runtime built into Function Compute, such as Node.js or Python, instead of a custom runtime or a custom image, use the local invocation feature of Serverless Devs for debugging. For more information, see Local command.
-
If your function uses a custom runtime or a custom image, you can debug the server-side code according to your normal development practices.
NoteFor custom runtimes, the
s local invokecommand can initiate a local invocation of the function, but breakpoint debugging is not supported.
Use the .fcignore file
The .fcignore file specifies files or folders to ignore when packaging function code into a ZIP file. For more information, see Use .fcignore.
Specify a function for deployment or invocation
A service in the s.yaml file can have multiple functions. To deploy or invoke only one of them, you can specify the resource name when you run the s deploy, s info, or s local invoke command. For example, the following sample s.yaml file contains multiple functions. To deploy only the helloworld1 function, you can run the s helloworld1 deploy command.
edition: 3.0.0
name: hello-world-app
access: "default"
resources:
hello_world1:
component: fc3
props:
region: cn-huhehaote
functionName: "hello_world1"
description: 'hello world1 by serverless devs'
runtime: "nodejs14"
code: ./code
handler: index.handler
hello_world2:
component: fc3
props:
region: cn-huhehaote
functionName: "hello_world2"
description: 'hello world2 by serverless devs'
runtime: "nodejs14"
code: ./code
handler: index.handler
Use Serverless Devs with Podman
When you use Serverless Devs with Podman to build a project or debug a function locally, you may see an error message like Failed to start docker, xxx. To resolve this issue, create a symbolic link that points from the Docker directory to the Podman directory. Then, build the project or debug locally again. The following steps describe how to create the symbolic link:
-
Find the path of the Podman executable file.
which podmanIn this example, the path of the Podman executable file is
/usr/bin/podman. -
Create the symbolic link.
ln -s /usr/bin/podman /usr/bin/docker -
Verify that the symbolic link has been created.
ls -lh /usr/bin/dockerThe following output is expected:
lrwxrwxrwx 1 root root 15 Jan 5 09:30 /usr/bin/docker -> /usr/bin/podman