在没有 systemd 的 Linux ec2(使用旧版本的 amazon Linux)上,正在尝试设置 init 进程以自动重启 presto 服务。
[[email protected] init]# cat /etc/os-release
NAME="Amazon Linux AMI"
VERSION="2018.03"
ID="amzn"
ID_LIKE="rhel fedora"
VERSION_ID="2018.03"
PRETTY_NAME="Amazon Linux AMI 2018.03"
ANSI_COLOR="0;33"
CPE_NAME="cpe:/o:amazon:linux:2018.03:ga"
HOME_URL="http://aws.amazon.com/amazon-linux-ami/"
[[email protected] init]# cat /etc/inittab | grep -v '^#'
id:3:initdefault:
pr:2345:respawn:/etc/init.d/presto start
pr1:2345:respawn:/bin/su - root -c "service presto start" -- tried starting the service this way as well to see if it helps
[[email protected] init]# chkconfig --list presto
presto 0:off 1:off 2:on 3:on 4:on 5:on 6:off
[[email protected] init]# cat /etc/init/presto.conf
start on runlevel [2345]
stop on starting rc RUNLEVEL=[016]
respawn
respawn limit 2 5
运行 telinit u 重新加载 init,终止正在运行的 presto 进程,但没有看到服务重生。我遗漏了什么吗?
[[email protected] init]# telinit u
[[email protected] init]# service presto status
Getting status for presto
Running as 29983
[[email protected] init]# kill -9 29983
-- waited for couple of mins, but dont see the service starting
[[email protected] init]# service presto status
Getting status for presto
Not running
答案1
在您的操作系统中使用旧的 initd 来管理守护进程。它不提供任何看门狗功能,因此如果您终止进程,则应手动重新启动它。使用service presto restart
或service presto condrestart
。