我希望asterisk
它mysql
能够在发生任何事情(例如崩溃)时自动重启。
我找到了一本包含我所需内容的指南,但该指南假设正在/etc/inittab
使用。如何将该指南转换为基于 upstart 的版本?
以下是指南:如何:自动重启 Asterisk
答案1
只需将respawn
-option 添加到你的 upstart-job (对于 mysql 或 asterisk) 即可。
您也可以此外添加-respawn limit
选项:
respawn limit COUNT INTERVAL
“如果该作业在 INTERVAL 秒内重生超过 COUNT 次,则会被认为存在更严重的问题并将被停止。”
例如
respawn
respawn limit 3 60
因此,如果您的进程崩溃,它将自动重新启动,但如果它在 60 秒内崩溃超过 3 次,它将不再重新启动。
文档:新贵食谱
以下是 asterisk 的一个 upstart-job 示例,取自http://www.digium.com/
# asterisk
#
# Upstart control file for the Asterisk PBX
#
# To install, rename this file to 'asterisk' and copy it to /etc/event.d/
# On Debian: copy to /etc/init/
#
# To start asterisk manually:
# sudo start asterisk
#
# To stop asterisk manually:
# sudo stop asterisk
#
# Asterisk is started with an "interactive console", though redirected
# to/from /dev/null . The concept of a main console is bad. OTOH, the main
# process should not detach from the console if we work with upstart and
# alike.
#
# The username 'asterisk' is currently hardwired here, and likewise the
# varrundir.
#
description "Asterisk PBX"
#version "1.8"
start on runlevel [2345]
stop on runlevel [!2345]
pre-start script
# Since Ubuntu clears /var/run on reboot, create this before we try to start
if [ ! -d /var/run/asterisk ]; then
mkdir -p asterisk /var/run/asterisk
chown asterisk: /var/run/asterisk
fi
end script
respawn
exec /usr/sbin/asterisk -U asterisk -g -f