This is the 8th day of my participation in the First Challenge 2022

Problem description

When the blogger deployed the egg.js project with Serverless, he directly used the Serverless deploy command because the project has been deployed many times, and then automatically installed the dependencies in the console of the cloud function. He found 405 error, which has never happened in normal times. Then I started a Bug check that took a whole afternoon. Here is the process of Bug check.

1. Check for code errors

The blogger first checked the updated code, and since the updated code was only a change in the API content returned from the back end, it was almost impossible to be the cause of the updated code, so the cause was ruled out.

2. View the latest documents

Here’s the official update:

  • Quickly deploy the Egg framework

By querying the official documents, we can find the following changes to the official documents.

In other words, we need to add an SCf_bootstrap startup file to the root directory of the project. By looking at the code of this file, we can see that we don’t need to modify anything, just copy it. So I added this file to the project, but after redeployment, it still reported 405 error, why is this?

3. Add permission to the file

After reviewing the documentation and consulting the relevant after-sales staff, they said they needed to add permissions to the startup file.

We can see that chmod is actually a Linux command, so how do we execute it on Windows? The answer is to run the git command line tool.

4. Ensure that the deployment file is consistent with the serverless application

One of the most important files in the Serverless project is the Serverless.yml configuration file, which needs to be consistent with the relevant information in our application.

5. Install dependencies from the command line of the cloud function

Automatic installation dependencies for cloud functions are sometimes ineffective, so it is important to install dependencies from the command line.

cd src
npm i
Copy the code

conclusion

To ensure the successful deployment of cloud functions, the key is to ensure the authorization of serverless.yml files and startup files.