This topic describes how to deploy a Tornado application to Function Compute. Function
Compute provides a method different from traditional deployment methods. You can deploy
a traditional Tornado application to Function Compute and use the application for
production without performing operations such as purchasing a server. The deployed
Tornado application can use the auto scaling, pay-as-you-go, and O&M-free features
of Function Compute.
Prerequisites
The following operations are complete:
Procedure
- Run the following command in the specified directory to initialize a project:
s init devsapp/start-tornado -d start-tornado
The
-d parameter specifies the project name. In this example, the project name is start-tornado.
Note Skip this step if the project already exists.
Sample command output:
Serverless Awesome: https://github.com/Serverless-Devs/package-awesome
devsapp!start-tornado@0.0.7.zip file decompression completed
please select credential alias default
_____ _
|_ _| | |
| | ___ _ __ _ __ __ _ __| | ___
| |/ _ \| '__| '_ \ / _` |/ _` |/ _ \
| | (_) | | | | | | (_| | (_| | (_) |
\_/\___/|_| |_| |_|\__,_|\__,_|\___/
Welcome to the start-tornado application
This application requires to open these services:
FC : https://fc.console.aliyun.com/
ACR: https://cr.console.aliyun.com/
This application can help you quickly deploy the Tornado project:
Full yaml configuration : https://github.com/devsapp/tornado#%E5%AE%8C%E6%95%B4yaml
Tornado development docs: https://www.tornadoweb.org/en/stable/
This application homepage: https://github.com/devsapp/start-tornado
Thanks for using Serverless-Devs
You could [cd /test/start-tornado] and enjoy your serverless journey!
If you need help for this example, you can use [s -h] after you enter folder.
Document Star: https://github.com/Serverless-Devs/Serverless-Devs
- Run the following command to go to the project directory:
- Run the following command to deploy the project:
s deploy
Sample command output:
[2021-08-30T17:41:56.340] [INFO ] [S-CLI] - Start ...
[2021-08-30T17:41:56.350] [INFO ] [S-CLI] - Start the pre-action
[2021-08-30T17:41:56.350] [INFO ] [S-CLI] - Action: pip3 install -t . -r requirements.txt
WARNING: Running pip install with root privileges is generally not a good idea. Try `pip3 install --user` instead.
Collecting tornado==6.0.4 (from -r requirements.txt (line 1))
Downloading http://mirrors.cloud.aliyuncs.com/pypi/packages/95/84/119a46d494f008969bf0c775cb2c6b3579d3c4cc1bb1b41a022aa93ee242/tornado-6.0.4.tar.gz (496 KB)
100% |████████████████████████████████| 501 KB 32.8 MB/s
Installing collected packages: tornado
Running setup.py install for tornado ... done
Successfully installed tornado-6.0.4
[2021-08-30T17:41:57.847] [INFO ] [S-CLI] - End the pre-action
Using web framework type: nas, If you want to deploy with container, you can [s cli fc-default set web-framework container] to switch.
(node:13961) [DEP0005] DeprecationWarning: Buffer() is deprecated due to security and usability issues. Please use the Buffer.alloc(), Buffer.allocUnsafe(), or Buffer.from() methods instead.
(Use `node --trace-deprecation ...` to show where the warning was created)
End of request
Deployed.
End of request
[2021-08-30T17:42:03.253] [INFO ] [FC-DEPLOY] - Using region: cn-shenzhen
[2021-08-30T17:42:03.254] [INFO ] [FC-DEPLOY] - Using access alias: default
[2021-08-30T17:42:03.254] [INFO ] [FC-DEPLOY] - Using accessKeyID: 188077086902****
[2021-08-30T17:42:03.255] [INFO ] [FC-DEPLOY] - Using accessKeySecret: ldHUiJLoGto****
Using fc deploy type: sdk, If you want to deploy with pulumi, you can [s cli fc-default set deploy-type pulumi] to switch.
[2021-08-30T17:42:03.608] [INFO ] [FC-DEPLOY] - Checking Service serverless-devs-tornado exists
[2021-08-30T17:42:03.784] [INFO ] [FC-DEPLOY] - Setting role: AliyunFCDefaultRole
[2021-08-30T17:42:03.884] [INFO ] [RAM] - Checking Role AliyunFCDefaultRole exists
[2021-08-30T17:42:04.004] [INFO ] [RAM] - Updating role: AliyunFCDefaultRole
[2021-08-30T17:42:04.107] [INFO ] [RAM] - Checking Plicy AliyunFCDefaultRolePolicy exists
[2021-08-30T17:42:04.253] [INFO ] [FC-DEPLOY] - Using vpcConfig: auto: fc will try to generate related vpc resources automatically
[2021-08-30T17:42:04.891] [INFO ] [VPC] - Getting vpc: fc-deploy-component-generated-vpc-cn-shenzhen
[2021-08-30T17:42:04.982] [INFO ] [VPC] - Getting vswitch: fc-deploy-component-generated-vswitch-cn-shenzhen
[2021-08-30T17:42:05.125] [INFO ] [VPC] - Getting securityGroup: fc-deploy-component-generated-securityGroup-cn-shenzhen
[2021-08-30T17:42:05.335] [INFO ] [FC-DEPLOY] - Generated vpcConfig:
securityGroupId: sg-wz92ctigpi221smc****
vSwitchId: vsw-wz9qnuult4q5g4f7n****
vpcId: vpc-wz9x9bzs0wtvjgt6n****
[2021-08-30T17:42:05.335] [INFO ] [FC-DEPLOY] - Using nasConfig: auto: fc will try to generate related nas file system automatically
[2021-08-30T17:42:21.530] [INFO ] [FC-DEPLOY] - Generated nasConfig:
groupId: 10003
mountPoints:
- fcDir: /mnt/auto
nasDir: /serverless-devs-tornado
serverAddr: example.com
userId: 10003
[2021-08-30T17:42:21.532] [INFO ] [FC-DEPLOY] - Checking Function tornado exists
[2021-08-30T17:42:21.648] [WARN ] [FC-DEPLOY] - Image registry.cn-shenzhen.aliyuncs.com/web-framework/python3:0.0.1 dose not exist locally.
Maybe you need to run 's build' first if it dose not exist remotely.
[2021-08-30T17:42:21.663] [INFO ] [FC-DEPLOY] - Checking Trigger serverless-devs-tornado exists
[2021-08-30T17:42:21.766] [INFO ] [FC-DEPLOY] - Checking Trigger serverless-devs-tornado exists
[2021-08-30T17:42:21.908] [INFO ] [FC-DEPLOY] - Creating service: serverless-devs-tornado
[2021-08-30T17:42:21.909] [INFO ] [FC-DEPLOY] - Creating function: tornado
[2021-08-30T17:42:21.909] [INFO ] [FC-DEPLOY] - Creating triggers: ["serverless-devs-tornado"]
Make service serverless-devs-tornado success.
Make function serverless-devs-tornado/tornado success.
Make trigger serverless-devs-tornado/tornado/serverless-devs-tornado success.
[2021-08-30T17:42:24.947] [INFO ] [FC-DEPLOY] - Checking Service serverless-devs-tornado exists
[2021-08-30T17:42:25.023] [INFO ] [FC-DEPLOY] - Checking Function tornado exists
[2021-08-30T17:42:25.157] [INFO ] [FC-DEPLOY] - Checking Trigger serverless-devs-tornado exists
[2021-08-30T17:42:25.374] [INFO ] [FC-DEPLOY] - Creating custom domain: tornado.serverless-devs-tornado.188077086902****.cn-shenzhen.fc.devsapp.net
[2021-08-30T17:42:26.033] [INFO ] [FC-DOMAIN] - Creating custom domain: tornado.serverless-devs-tornado.188077086902****.cn-shenzhen.fc.devsapp.net
There is auto config in the service: serverless-devs-tornado
[2021-08-30T17:42:26.484] [INFO ] [WEB-FRAMEWORK] - nas component get src is: ./src
Packing ...
Package complete.
Start uploading file: /mnt/2bfb748534-tpm20-cn-shenzhen/serverless-devs-tornado/tornado/src.zip
File uploaded successfully: /mnt/2bfb748534-tpm20-cn-shenzhen/serverless-devs-tornado/tornado/src.zip
upload done
[2021-08-30T17:43:01.283] [INFO ] [FC-NAS] - unzipping file
[2021-08-30T17:43:02.783] [INFO ] [FC-NAS] - unzip done
Try container acceleration
framework-test:
region: cn-shenzhen
serviceName: serverless-devs-tornado
functionName: tornado
customDomains:
- >-
http://tornado.serverless-devs-tornado.188077086902****.cn-shenzhen.fc.devsapp.net
Result
After the project is deployed, you can view the temporary domain name that is generated
by Function Compute in the output. The temporary domain name can be used to access
the newly deployed application. For example, run the following command to access the
application:
curl http://tornado.serverless-devs-tornado.188077086902****.cn-shenzhen.fc.devsapp.net
Note You can use the temporary domain name only for demonstration and development purposes.
It is valid for a limited period of time. In a production environment, you must use
a domain name for which an Internet Content Provider (ICP) filing is obtained from
Alibaba Cloud. For more information, see
Configure a custom domain name.