【发布时间】:2012-09-21 13:35:08
【问题描述】:
我正在使用以下命令启动 HA 代理:
sudo etc/init.d/haproxy start
我使用以下命令停止 HA 代理:
sudo etc/init.d/haproxy stop
如何为 sudo etc/init.d/something start 或 stop 编写基本的 upstart 脚本?
【问题讨论】:
我正在使用以下命令启动 HA 代理:
sudo etc/init.d/haproxy start
我使用以下命令停止 HA 代理:
sudo etc/init.d/haproxy stop
如何为 sudo etc/init.d/something start 或 stop 编写基本的 upstart 脚本?
【问题讨论】:
以下脚本将起作用。把它放在“/etc/init/haproxy.conf”中,然后就可以用“service haproxy start”启动haproxy服务了。一定要检查配置文件的位置
# HAProxy
description "HAProxy"
start on runlevel [2345]
stop on runlevel [016]
respawn
respawn limit 2 5
env CONF=/etc/haproxy/haproxy.cfg
pre-start script
[ -r $CONF ]
end script
exec /usr/local/sbin/haproxy -db -f $CONF
【讨论】: