1

我是 HA 代理和 Upstart 脚本的新手。我正在使用 HA 代理版本 1.4.18 2011/09/16。我正在尝试编写一个新贵脚本,以防 haproxy 死亡时保持 haproxy 存活。这就是我目前所拥有的:

script
if [ $(pgrep haproxy) ]; 然后
重启haproxy;
否则
启动 haproxy;
fi
end script

看起来像清晰的代码吗?

4

1 回答 1

3

如果你想让它成为最书呆子和单行脚本:

[ $(pgrep haproxy) ] && restart haproxy || start haproxy

顺便说一句 .. 最简单和最好的方法是使用这样的 init.d 自定义脚本:http: //mattiasgeniar.be/2010/11/04/a-custom-init-d-start-up-script -for-haproxy-start-stop-restart-reload-checkconfig/

于 2012-10-31T22:23:59.493 回答