You can migrate web projects in C++ by using the custom runtime and HTTP triggers of Function Compute. You can access a function by using a browser or HTTP client tools such as cURL. You can modify the C++ sample code as needed for custom development.
- Run the following command to initialize a project:
s init fc-custom-cpp-http -d fc-custom-cpp-httpNote
-dspecifies the name of the folder in which the sample project resides. You can customize the folder name as required.
- Run the following command to go to the project directory:
- Optional: Modify the
HttpHandler::OnInitializeparameters in the /sample/src/handlers/http_handler.cpp sample file for custom development.
- Run the following command to deploy the project:
Sample command output:
s deploy -y
[2022-01-27 06:52:54] [INFO] [S-CLI] - Start the pre-action [2022-01-27 06:52:54] [INFO] [S-CLI] - Action: make build docker build -t fc-cpp-runtime -f build-image/Dockerfile build-image Sending build context to Docker daemon 2.048kB Step 1/3 : FROM aliyunfc/runtime-custom:base ...... [2022-01-27 06:54:51] [INFO] [S-CLI] - End the pre-action Checking Service, Function, Triggers (1.8s) Creating Service, Function, Triggers (4.5s) Generated custom domain (1.36s) Creating custom domain (2.6s) Tips for next step ====================== * Display information of the deployed resource: s info * Display metrics: s metrics * Display logs: s logs * Invoke remote function: s invoke * Remove Service: s remove service * Remove Function: s remove function * Remove Trigger: s remove trigger * Remove CustomDomain: s remove domain helloworld: region: cn-hangzhou service: name: hello-world-service function: name: cppHttpFunc runtime: custom handler: index.handler memorySize: 512 timeout: 3 url: system_url: https://188077086902****.cn-hangzhou.fc.aliyuncs.com/2016-08-15/proxy/hello-world-service/cppHttpFunc/ custom_domain: - domain: http://cpphttpfunc.hello-world-service.188077086902****.cn-hangzhou.fc.devsapp.net triggers: - type: http name: http_t
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: