Files
BiliBiliToolPro/tencentScf/bootstrap
database-mysql e519cac94e
Some checks failed
CodeQL / Analyze (csharp) (push) Has been cancelled
Close Stale Issues / close_stale_issues (push) Has been cancelled
repo-sync / repo-sync (push) Has been cancelled
auto-deploy-tencent-scf / pre-check (push) Has been cancelled
auto-deploy-tencent-scf / deploy serverless (push) Has been cancelled
pull file
2026-02-11 23:32:56 +08:00

26 lines
908 B
Bash
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#! /bin/bash
set -euo pipefail
FuncFile="$(echo $_HANDLER | cut -d. -f1).sh"
echo "[step 1]初始化,开始加载函数文件 $FuncFile"
source ./$FuncFile
echo "=>完成"
echo "[step 2]初始化完成开始发送ready信号"
curl -d " " -X POST -s "http://$SCF_RUNTIME_API:$SCF_RUNTIME_API_PORT/runtime/init/ready"
echo "=>完成"
echo "[step 3]开始循环监听处理事件调用"
while true
do
HEADERS="$(mktemp)"
echo "=>长轮询获取事件"
EVENT_DATA=$(curl -sS -LD "$HEADERS" -X GET -s "http://$SCF_RUNTIME_API:$SCF_RUNTIME_API_PORT/runtime/invocation/next")
echo "=>监听到事件:$EVENT_DATA"
echo "=>调用函数,开始处理事件"
$(echo "$_HANDLER" | cut -d. -f2) "$EVENT_DATA"
RESPONSE=$EVENT_DATA
echo "=>返回 $RESPONSE"
echo "=>推送函数处理结果"
curl -X POST -s "http://$SCF_RUNTIME_API:$SCF_RUNTIME_API_PORT/runtime/invocation/response" -d "$RESPONSE"
done