wait-for
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"]
随机推荐
- Qt程序继承QApplication发生崩溃的原因
一.前情介绍 QApplication是Qt开发中经常用到的一个类,用来管理应用程序的生命周期.跟其相关的类还有QCoreApplication和QGuiApplication,分别用于不同场景下为应 ...
- iOS APP提交上架流程
转载自CocoaChina,链接地址:http://www.cocoachina.com/bbs/read.php?tid=330302 后面问题我也遇到了,参考该文章解决的 转自http://blo ...
- 使用 universalimageloader 缓存图片的配置类及使用方法
0.gradle 配置 dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) testCompile 'junit:juni ...
- 虚拟机中操作系统的克隆方法及ip修改及硬件地址修改
1.把复制的操作系统关机 2.点击右键->管理->克隆->下一步->虚拟机当前状态->创建完整虚拟机->修改虚拟机名称 位置 3.修改主机名 4.修改主机名与ip ...
- Redis自学笔记:4.1进阶-事务
第4章:进阶 4.1事务 4.1.1概述 redis中的事务是一组命令的集合 事务同命令一样都是redis的最小执行单位,一个事务中的命令要么都执行, 要么都不执行 事务的原理是先将一个事务的命令发送 ...
- 2018.12.1 Test
目录 2018.12.1 Test A 串string(思路) B 变量variable(最小割ISAP) C 取石子stone(思路 博弈) 考试代码 B C 2018.12.1 Test 题目为2 ...
- Java -- 内部类(一)
什么是内部类 将一个类的定义放在另一个类的定义内部,这就是内部类.在Java中内部类主要分为成员内部类.局部内部类.匿名内部类.静态内部类.举个栗子: public class A { public ...
- Java笔记(一)编程基础与二进制
编程基础与二进制 一.编程基础 函数调用的基本原理: 函数调用中的问题: 1)参数如何传递? 2)函数如何知道返回什么地方? 3)函数结果如何传递给调用方? 解决思路是使用内存来函数调用过程中需要的数 ...
- 潭州课堂25班:Ph201805201 tornado 项目 第四课 增加用户注册登录(课堂笔记)
tornado 相关说明 在 handlers 中创建个 auth.py 用来做用户登录,在这文件中创建个类,并逐步完善 在 tornado 中创建 login.html 文件,是个登录页面 {% e ...
- vue的生存周期
钩子函数 created 实例已经创建 befoCompile 编译之前 compiled 编译之后 ready 插入到文档 beforeDestroy 销毁之前 destroyed 销毁之后