函数工作流 FUNCTIONGRAPH-开发事件函数示例:步骤三:本地验证

时间:2024-05-20 15:43:35

步骤三:本地验证

  1. 启动docker容器
    docker run -u 1003:1003 -p 8000:8000 custom_container_event_example:latest
  1. 打开一个新的命令行窗口,向开放的8000端口发送消息,访问模板代码中指定的/init路径
    curl -XPOST -H 'Content-Type: application/json' localhost:8000/init

    按照模块代码中返回

    Hello init
  1. 打开一个新的命令行窗口,向开放的8000端口发送消息,访问模板代码中指定的/invoke路径
    curl -XPOST -H 'Content-Type: application/json' -d '{"message":"HelloWorld"}' localhost:8000/invoke

    按照模块代码中返回

    Hello invoke
  1. 在容器启动端口可以看到
    Listening on http://localhost:8000
    receive {}
    receive { message: 'HelloWorld' }

    或者使用docker logs命令获取容器的日志

support.huaweicloud.com/qs-functiongraph/functiongraph_04_0104.html