通过函数计算的Custom Runtime,您可以在函数计算平台使用Lua来编写函数。本文介绍快速部署和调用Lua函数的详细步骤。您可以修改Lua示例中的代码,实现自己的需求。
前提条件
说明 如果您已安装Funcraft可直接跳转至步骤二:部署和调用函数。
步骤一:准备环境
安装Funcraft,最简单的方式就是直接下载可执行的二进制文件。
通过函数计算的Custom Runtime,您可以在函数计算平台使用Lua来编写函数。本文介绍快速部署和调用Lua函数的详细步骤。您可以修改Lua示例中的代码,实现自己的需求。
安装Funcraft,最简单的方式就是直接下载可执行的二进制文件。
fun --version
检查安装是否成功。fun config
配置Funcraft。然后按照提示依次配置Account ID、Access Key ID、Access Key Secret、Default region name。fun config
Aliyun Account ID 1234xxx
Aliyun Access Key ID xxxx
Aliyun Access Key Secret xxxx
Default region name cn-xxxx
The timeout in seconds for each SDK client invoking 300
The maximum number of retries for each SDK client 5
Allow to anonynously report usage statistics to improve the tool over time? (Y/n)
git clone https://github.com/awesome-fc/fc-custom-demo
cd fc-custom-demo
cd lua-demo
fun deploy -y
...
Waiting for service lua-demo to be deployed...
Waiting for function fc-lua to be deployed...
Waiting for packaging function fc-lua code...
The function fc-lua has been packaged. A total of 7 files were compressed and the final size was 10.62 MB
function fc-lua deploy success
service lua-demo deploy success
fun invoke -e "Hello World"
...
========= FC invoke Logs begin =========
FC Invoke Start RequestId: dcc2ff81-2318-4a89-abae-c181ede22b79, client: 21.0.3.254, server: , request: "POST /invoke HTTP/1.1", host: "21.0.3.1:9000"
2020/05/10 13:16:21 [notice] 7#7: *2 [lua] main.lua:17: FC Invoke End RequestId: dcc2ff81-2318-4a89-abae-c181ede22b79, client: 21.0.3.254, server: , request: "POST /invoke HTTP/1.1", host: "21.0.3.1:9000"
21.0.3.1 21.0.3.254 0.000 [10/May/2020:13:16:21 +0000] "POST /invoke HTTP/1.1" 200 22 "-" "Go-http-client/1.1" "-" dcc2ff81-2318-4a89-abae-c181ede22b79
Duration: 3.42 ms, Billed Duration: 100 ms, Memory Size: 512 MB, Max Memory Used: 4.66 MB
========= FC invoke Logs end =========
FC Invoke Result:
Hello World
在文档使用中是否遇到以下问题
更多建议
匿名提交