# 之前一直在supervisor使用如下配置来启动ES,但是仔细观察Docker的控制台输出会发现如下的错误
[program:elasticsearch]
command=/{ES_HOME}/bin/elasticsearch -d
INFO success: elasticsearch entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)
INFO exited: elasticsearch (exit status 1; not expected)
INFO spawned: 'elasticsearch' with pid 12
INFO exited: elasticsearch (exit status 1; not expected)
INFO spawned: 'elasticsearch' with pid 13
INFO exited: elasticsearch (exit status 1; not expected)
INFO gave up: elasticsearch entered FATAL state, too many start retries too quickly
# 这里使用supervisorctl status查看supervisor监控的所有服务,就会发现ES没有处于被监控状态
$ supervisorctl status
elasticsearch FATAL Exited too quickly (process log may have details)
sshd RUNNING pid 6, uptime 0:01:49
tomcat RUNNING pid 8, uptime 0:01:49
# 所以这里修改supervisor配置方式如下,修改为不自动重启ES,并且改成非daemon,DFOREGROUND的方式运行,supervisor就可以监控到了
[program:elasticsearch]
startsecs = 0
autorestart = false
command=/bin/bash -c "exec ${ES_HOME}/bin/elasticsearch -DFOREGROUND"
# 这里说明一下supervisor启动多个服务,要求所有启动的服务都是非daemon的方式启动,否则就会遇到如上的问题,autorestart设置为false只是为了让supervisor启动报错的时候不会重复启动,只要改成非daemon的方式启动ES,可以设置autorestart为true