In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
In this issue, the editor will bring you about how to deploy the Serverless takeout order system based on API gateway and cloud function SCF. The article is rich in content and analyzes and describes it from a professional point of view. I hope you can get something after reading this article.
The usage scenarios of API gateway combined with cloud function SCF are very rich. The editor will introduce how to quickly deploy Serverless takeout order system based on API gateway and cloud function SCF.
Typical scenarios used for message push
Takeout order system architecture diagram
Demo actual combat 1. Install Serverless Frameworknpm install-g serverless2. Initialize the project template sls init-t websocket-order3. View the project directory
After downloading to the local area, check the directory structure of the project as follows:
It contains DB, gateway, function and other sub-modules.
The db directory is used to create a PG Serverless database instance
Apigateway is used to create the corresponding API:
/ bill place order API,HTTP type
/ get_shop_info, get the store menu API
/ pgws, the websocket API used for message push
The list of functions is as follows:
Register the function ws_register.py to configure the environment variables of DB
Transfer function ws_trans.py, configure DB environment variables and apiid= message push API
Logout function ws_unregister.py, configure DB environment variables and apiid= message push API
Message push related functions:
Order function bill.py, configure DB environment variables and apiid= message push API
Pull the store information function get_shop_info.py to configure the environment variables of DB
Initialize the DB function init_db.py to configure the environment variables of DB
4. Modify configuration information. Change the .env.example file to a .env file, and get SecretId and SecretKey in API key management. # secret for credentialTENCENT_SECRET_ID=xxxxxxTENCENT_SECRET_KEY=xxxxxx# global configREGION=ap-shanghai
Project deployment
Sls deploy-- all6. Update configuration and deployment
Execute the init_db-dev function to initialize the database. In the console or vscode plug-in, click the test init_db-dev function to initialize the database and create tables.
Update the apiid configuration, deploy again to view the output information, configure the apiid of websocket API in the serverless.yml of the function_bill directory and the function_ws_trans directory, and redeploy the two functions to refresh the environment variable configuration.
Sls deploy-target=./function_ws_trans sls deploy-target=./function_bill7. Change the address of the client and the kitchen order system
App ordering system .html changes line 29 and line 88 xxxx is: the generated API gateway service domain name
The store kitchen system .html changes 17 lines of xxxx to the service domain name of API gateway
Demonstration of the effect:
The above is how to deploy the Serverless takeout order system based on API gateway and cloud function SCF. If you happen to have similar doubts, please refer to the above analysis to understand. If you want to know more about it, you are welcome to follow the industry information channel.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.