← 返回命令列表

Linux command

serverless 命令

文本

复制后可按需替换文件名、目录或参数。

常用示例

Create new service

serverless create --template [aws-nodejs] --name [my-service]

Deploy service

serverless deploy

Deploy single function

serverless deploy function -f [functionName]

Invoke function

serverless invoke -f [functionName]

View logs

serverless logs -f [functionName]

Remove service

serverless remove

Run locally

serverless invoke local -f [functionName]

Print config

serverless print

说明

serverless (sls) is a framework for building serverless applications. It deploys functions to AWS Lambda, Azure Functions, Google Cloud Functions, and others. Service configuration in serverless.yml defines functions, events, and resources. Events trigger functions from HTTP, queues, schedules, and other sources. Deployment packages code and provisions infrastructure. CloudFormation (AWS) or equivalent handles resource creation. Local invocation tests functions without deployment. This speeds up development iteration. Logs stream function output from cloud providers. They show invocations, errors, and execution details. Plugins extend functionality: custom domains, monitoring, optimization, and framework integrations.

参数

create
Create new service.
deploy
Deploy service.
deploy function
Deploy single function.
invoke -f _FUNC_
Invoke function.
invoke local
Invoke locally.
logs -f _FUNC_
View function logs.
remove
Remove service.
package
Package without deploying.
print
Print configuration.
--template, -t _TPL_
Project template.
--name, -n _NAME_
Service name.
--stage, -s _STAGE_
Deployment stage.
--region, -r _REGION_
AWS region.
--config, -c _FILE_
Config file.

FAQ

What is the serverless command used for?

serverless (sls) is a framework for building serverless applications. It deploys functions to AWS Lambda, Azure Functions, Google Cloud Functions, and others. Service configuration in serverless.yml defines functions, events, and resources. Events trigger functions from HTTP, queues, schedules, and other sources. Deployment packages code and provisions infrastructure. CloudFormation (AWS) or equivalent handles resource creation. Local invocation tests functions without deployment. This speeds up development iteration. Logs stream function output from cloud providers. They show invocations, errors, and execution details. Plugins extend functionality: custom domains, monitoring, optimization, and framework integrations.

How do I run a basic serverless example?

Run `serverless create --template [aws-nodejs] --name [my-service]` in a terminal, then adjust file names, paths, flags, or remote targets for your system.

What does create do in serverless?

Create new service.