wait-for
2024-08-25 13:23:16
Use a tool such as wait-for-it, dockerize, or sh-compatible wait-for. These are small wrapper scripts which you can include in your application’s image to poll a given host and port until it’s accepting TCP connections. For example, to use wait-for-it.sh or wait-for to wrap your service’s command: version: ""
services:
web:
build: .
ports:
- "80:8000"
depends_on:
- "db"
command: ["./wait-for-it.sh", "db:5432", "--", "python", "app.py"]
db:
image: postgres
Tip: There are limitations to this first solution. For example, it doesn’t verify when a specific service is really ready. If you add more arguments to the command, use the bash shift command with a loop, as shown in the next example. Alternatively, write your own wrapper script to perform a more application-specific health check. For example, you might want to wait until Postgres is definitely ready to accept commands: #!/bin/bash
# wait-for-postgres.sh set -e host="$1"
shift
cmd="$@" until psql -h "$host" -U "postgres" -c '\q'; do
>& echo "Postgres is unavailable - sleeping"
sleep
done >& echo "Postgres is up - executing command"
exec $cmd
You can use this as a wrapper script as in the previous example, by setting: command: ["./wait-for-postgres.sh", "db", "python", "app.py"]
最新文章
- web app开发之rem
- 解决mac安装grunt时出现[command not found]的错误
- Android基础类之BaseAdapter
- Hbase的连接池--HTablePool被Deprecated之后
- 本地安装gem install --local redis-stat-0.4.13.gem
- linux同步
- MongoDB入门简单介绍
- [AngularJS] 5 simple ways to speed up your AngularJS application
- E - QS Network - zoj 1586(简单)
- RPC通信框架——RCF介绍(替换COM)
- BCM策略路由交换芯片
- php随意笔记
- 深入NGINX:nginx高性能的实现原理
- element框架中表格的筛选功能使用说明(转载)
- ueditor 使用
- 【GMT43智能液晶模块】例程八:ADC实验——电源监控
- Visual Studio 10.0设置引用HalconDotNet.dll
- hadoop ha环境下的datanode启动报错java.lang.NumberFormatException: For input string: ";10m";
- [EffectiveC++]item28:避免返回handles指向对象内部成分
- [整理]基于bootstrap的文本编辑器
热门文章
- Linux安装Tomcat-Nginx-FastDFS-Redis-Solr-集群——【第九集-补充-之安装jdk】
- 无向图的 DFS 和 BFS实现 (以邻接表存储的图)
- js判断上传图片文件大小,尺寸,格式
- CentOS 7 休眠系统
- Gym 102091K The Stream of Corning 2【线段树】
- Codeforces Round #530 (Div. 2)
- SQL 2016 正式版 安装过程
- 765. 有效的三角形.md
- 8. Rotate String
- Serializers 序列化组件