Gitlab 管道 + docker : (7) 无法连接到本地主机端口 9000:连接拒绝
Gitlab piepline + docker : (7) Failed to connect to localhost port 9000: Connection refuse
我是编写管道的新手,下面是我正在尝试的工作运行
test website:
image: node
stage: test
script:
- npm i
- npm i -g gatsby-cli
- gatsby serve &
- sleep 3
- curl "http://localhost:9000" | grep -q "Gatsby"
但是在日志下面的最后一步失败了
gatsby serve &
$ sleep 3
$ curl "http://localhost:9000" | grep -q "Gatsby"
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0curl: (7) Failed to connect to localhost port 9000: Connection refused
ERROR: Job failed: exit code 1
请帮我解决这个问题,也帮我理解错误。
该错误消息表示 运行localhost:9000 上没有任何内容。检查您的应用程序是否实际配置为端口 9000 上的 运行,如果是,请尝试将您的 curl 请求推迟几秒钟以允许应用程序初始化。
我遇到了类似的问题。 google 搜索后,我发现 gatsby 服务器没有足够的时间启动,所以我增加了睡眠时间。后来管道输出一个不同的代码错误 (23) Failed writing body
这里似乎脚本管道有问题 curl "http://localhost:9000" | grep -q "Gatsby"
。
这个 answer 解释了为什么这种管道程序会发生这个错误,所以我就这样结束了,
test website:
image: node
stage: test
script:
- npm i
- npm i -g gatsby-cli
- gatsby serve &
- sleep 10
- curl "http://localhost:9000" | tac | tac | grep -q "Gatsby"
我的管道成功了,希望我的回答对你有所帮助
我是编写管道的新手,下面是我正在尝试的工作运行
test website:
image: node
stage: test
script:
- npm i
- npm i -g gatsby-cli
- gatsby serve &
- sleep 3
- curl "http://localhost:9000" | grep -q "Gatsby"
但是在日志下面的最后一步失败了
gatsby serve &
$ sleep 3
$ curl "http://localhost:9000" | grep -q "Gatsby"
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0curl: (7) Failed to connect to localhost port 9000: Connection refused
ERROR: Job failed: exit code 1
请帮我解决这个问题,也帮我理解错误。
该错误消息表示 运行localhost:9000 上没有任何内容。检查您的应用程序是否实际配置为端口 9000 上的 运行,如果是,请尝试将您的 curl 请求推迟几秒钟以允许应用程序初始化。
我遇到了类似的问题。 google 搜索后,我发现 gatsby 服务器没有足够的时间启动,所以我增加了睡眠时间。后来管道输出一个不同的代码错误 (23) Failed writing body
这里似乎脚本管道有问题 curl "http://localhost:9000" | grep -q "Gatsby"
。
这个 answer 解释了为什么这种管道程序会发生这个错误,所以我就这样结束了,
test website:
image: node
stage: test
script:
- npm i
- npm i -g gatsby-cli
- gatsby serve &
- sleep 10
- curl "http://localhost:9000" | tac | tac | grep -q "Gatsby"
我的管道成功了,希望我的回答对你有所帮助