我们在CI构建中使用ngrok,以便使用第三方服务测试API。这已经证明是相当成功的,除了支持并发构建似乎要困难得多。
为了支持并发性,我们决定保留域,让我们说:
我编写了一个脚本来检查可用域,并使用它找到的第一个可用域。脚本很粗糙,当我们尝试使用已经在使用的子域时,它依赖于ngrok终止:
#!/bin/bash
wget https://dl.ngrok.com/ngrok_2.0.19_linux_amd64.zip
unzip ngrok_2.0.19_linux_amd64.zip
./ngrok authtoken <account_token>
./ngrok http -subdomain=custom-domain 5000 &
sleep 5
curl http://localhost:4040/status
if [[ $? -eq 0 ]]
then
export HOST=custom-domain.ngrok.io
else
./ngrok http -subdomain=custom-domain2 5000 &
sleep 5
curl http://localhost:4040/status
if [[ $? -eq 0 ]]
then
export HOST=custom-domain2.ngrok.io
else
./ngrok http -subdomain=custom-domain3 5000 &
sleep 5
curl http://localhost:4040/status
if [[ $? -eq 0 ]]
then
export HOST=custom-domain3.ngrok.io
else
exit 1
fi
fi
fi我试着用客户端API重构它,但是客户端API只查看localhost,它不知道互联网上其他地方正在使用的子域。我正在寻找的似乎是可能的,因为ngrok.io网站本身也列出了目前正在使用的子域,我只需要弄清楚他们是如何做到的?我使用的是2.0版本。
使用脚本方法,它在使用custom-domain时确实有效,但当使用2或3时,我们似乎会在POST到端点时出现错误,日志中唯一可疑的事情是:
(有些数字有所改变)
t=2015-12-21T16:03:17+0000 lvl=warn msg="failed to open private leg" id=094b633d8754 privaddr=localhost:4567 err="dial tcp 127.0.0.1:4567: connection refused"
发布于 2021-04-08 07:28:36
ngrok的REST有一个列出所有在线隧道的端点。
列出当前在帐户上运行的所有在线隧道。
https://stackoverflow.com/questions/34439739
复制相似问题