[docker-pmon]: use service dependency in supervisord to start services
This commit is contained in:
parent
1636be4b68
commit
8da46d26c3
@ -55,8 +55,8 @@ RUN apt-get purge -y \
|
||||
/python-wheels \
|
||||
~/.cache
|
||||
|
||||
COPY ["docker_init.sh", "lm-sensors.sh", "/usr/bin/"]
|
||||
COPY ["docker-pmon.supervisord.conf.j2", "start.sh.j2", "/usr/share/sonic/templates/"]
|
||||
COPY ["docker_init.sh", "lm-sensors.sh", "start.sh", "/usr/bin/"]
|
||||
COPY ["docker-pmon.supervisord.conf.j2", "/usr/share/sonic/templates/"]
|
||||
COPY ["ssd_tools/*", "/usr/bin/"]
|
||||
COPY ["files/supervisor-proc-exit-listener", "/usr/bin"]
|
||||
COPY ["critical_processes", "/etc/supervisor"]
|
||||
|
@ -3,30 +3,41 @@ logfile_maxbytes=1MB
|
||||
logfile_backups=2
|
||||
nodaemon=true
|
||||
|
||||
[eventlistener:dependent-startup]
|
||||
command=python -m supervisord_dependent_startup
|
||||
autostart=true
|
||||
autorestart=unexpected
|
||||
startretries=0
|
||||
exitcodes=0,3
|
||||
events=PROCESS_STATE
|
||||
|
||||
[eventlistener:supervisor-proc-exit-listener]
|
||||
command=/usr/bin/supervisor-proc-exit-listener --container-name pmon
|
||||
events=PROCESS_STATE_EXITED
|
||||
autostart=true
|
||||
autorestart=unexpected
|
||||
|
||||
[program:start.sh]
|
||||
command=/usr/bin/start.sh
|
||||
[program:rsyslogd]
|
||||
command=/usr/sbin/rsyslogd -n -iNONE
|
||||
priority=1
|
||||
autostart=true
|
||||
autostart=false
|
||||
autorestart=false
|
||||
stdout_logfile=syslog
|
||||
stderr_logfile=syslog
|
||||
startsecs=0
|
||||
dependent_startup=true
|
||||
|
||||
[program:rsyslogd]
|
||||
command=/usr/sbin/rsyslogd -n
|
||||
[program:start]
|
||||
command=/usr/bin/start.sh
|
||||
priority=2
|
||||
autostart=false
|
||||
autorestart=false
|
||||
stdout_logfile=syslog
|
||||
stderr_logfile=syslog
|
||||
startsecs=0
|
||||
dependent_startup=true
|
||||
dependent_startup_wait_for=rsyslogd:running
|
||||
|
||||
{% if not skip_sensors %}
|
||||
{% if not skip_sensors and HAVE_SENSORS_CONF == 1 %}
|
||||
[program:lm-sensors]
|
||||
command=/usr/bin/lm-sensors.sh
|
||||
priority=3
|
||||
@ -35,9 +46,11 @@ autorestart=false
|
||||
stdout_logfile=syslog
|
||||
stderr_logfile=syslog
|
||||
startsecs=0
|
||||
dependent_startup=true
|
||||
dependent_startup_wait_for=start:exited
|
||||
{% endif %}
|
||||
|
||||
{% if not skip_fancontrol %}
|
||||
{% if not skip_fancontrol and HAVE_FANCONTROL_CONF == 1 %}
|
||||
[program:fancontrol]
|
||||
command=/usr/sbin/fancontrol
|
||||
priority=4
|
||||
@ -46,6 +59,8 @@ autorestart=unexpected
|
||||
stdout_logfile=syslog
|
||||
stderr_logfile=syslog
|
||||
startsecs=10
|
||||
dependent_startup=true
|
||||
dependent_startup_wait_for=start:exited
|
||||
{% endif %}
|
||||
|
||||
{% if not skip_ledd %}
|
||||
@ -57,6 +72,8 @@ autorestart=false
|
||||
stdout_logfile=syslog
|
||||
stderr_logfile=syslog
|
||||
startsecs=0
|
||||
dependent_startup=true
|
||||
dependent_startup_wait_for=start:exited
|
||||
{% endif %}
|
||||
|
||||
{% if not skip_xcvrd %}
|
||||
@ -68,6 +85,8 @@ autorestart=false
|
||||
stdout_logfile=syslog
|
||||
stderr_logfile=syslog
|
||||
startsecs=0
|
||||
dependent_startup=true
|
||||
dependent_startup_wait_for=start:exited
|
||||
{% endif %}
|
||||
|
||||
{% if not skip_psud %}
|
||||
@ -79,6 +98,8 @@ autorestart=false
|
||||
stdout_logfile=syslog
|
||||
stderr_logfile=syslog
|
||||
startsecs=0
|
||||
dependent_startup=true
|
||||
dependent_startup_wait_for=start:exited
|
||||
{% endif %}
|
||||
|
||||
{% if not skip_syseepromd %}
|
||||
@ -90,6 +111,8 @@ autorestart=unexpected
|
||||
stdout_logfile=syslog
|
||||
stderr_logfile=syslog
|
||||
startsecs=10
|
||||
dependent_startup=true
|
||||
dependent_startup_wait_for=start:exited
|
||||
{% endif %}
|
||||
|
||||
{% if not skip_thermalctld %}
|
||||
@ -101,4 +124,6 @@ autorestart=unexpected
|
||||
stdout_logfile=syslog
|
||||
stderr_logfile=syslog
|
||||
startsecs=10
|
||||
dependent_startup=true
|
||||
dependent_startup_wait_for=start:exited
|
||||
{% endif %}
|
||||
|
@ -3,16 +3,40 @@
|
||||
# Generate supervisord config file and the start.sh scripts
|
||||
mkdir -p /etc/supervisor/conf.d/
|
||||
|
||||
if [ -e /usr/share/sonic/platform/pmon_daemon_control.json ];
|
||||
|
||||
HAVE_SENSORS_CONF=0
|
||||
HAVE_FANCONTROL_CONF=0
|
||||
|
||||
if [ -e /usr/share/sonic/platform/sensors.conf ]; then
|
||||
HAVE_SENSORS_CONF=1
|
||||
fi
|
||||
|
||||
if [ -e /usr/share/sonic/platform/fancontrol ]; then
|
||||
HAVE_FANCONTROL_CONF=1
|
||||
fi
|
||||
|
||||
confvar="{\"HAVE_SENSORS_CONF\":$HAVE_SENSORS_CONF, \"HAVE_FANCONTROL_CONF\":$HAVE_FANCONTROL_CONF}"
|
||||
|
||||
if [ -e /usr/share/sonic/platform/pmon_daemon_control.json ];
|
||||
then
|
||||
sonic-cfggen -j /usr/share/sonic/platform/pmon_daemon_control.json -t /usr/share/sonic/templates/docker-pmon.supervisord.conf.j2 > /etc/supervisor/conf.d/supervisord.conf
|
||||
sonic-cfggen -j /usr/share/sonic/platform/pmon_daemon_control.json -t /usr/share/sonic/templates/start.sh.j2 > /usr/bin/start.sh
|
||||
chmod +x /usr/bin/start.sh
|
||||
sonic-cfggen -j /usr/share/sonic/platform/pmon_daemon_control.json -a "$confvar" -t /usr/share/sonic/templates/docker-pmon.supervisord.conf.j2 > /etc/supervisor/conf.d/supervisord.conf
|
||||
else
|
||||
sonic-cfggen -t /usr/share/sonic/templates/docker-pmon.supervisord.conf.j2 > /etc/supervisor/conf.d/supervisord.conf
|
||||
sonic-cfggen -t /usr/share/sonic/templates/start.sh.j2 > /usr/bin/start.sh
|
||||
chmod +x /usr/bin/start.sh
|
||||
sonic-cfggen -a "$confvar" -t /usr/share/sonic/templates/docker-pmon.supervisord.conf.j2 > /etc/supervisor/conf.d/supervisord.conf
|
||||
fi
|
||||
|
||||
# If this platform has an lm-sensors config file, copy it to it's proper place.
|
||||
if [ -e /usr/share/sonic/platform/sensors.conf ]; then
|
||||
mkdir -p /etc/sensors.d
|
||||
/bin/cp -f /usr/share/sonic/platform/sensors.conf /etc/sensors.d/
|
||||
fi
|
||||
|
||||
# If this platform has a fancontrol config file, copy it to it's proper place
|
||||
# and start fancontrol
|
||||
if [ -e /usr/share/sonic/platform/fancontrol ]; then
|
||||
# Remove stale pid file if it exists
|
||||
rm -f /var/run/fancontrol.pid
|
||||
|
||||
/bin/cp -f /usr/share/sonic/templates/fancontrol.conf /etc/supervisord/conf.d/
|
||||
fi
|
||||
|
||||
exec /usr/bin/supervisord
|
||||
|
||||
|
33
dockers/docker-platform-monitor/start.sh
Executable file
33
dockers/docker-platform-monitor/start.sh
Executable file
@ -0,0 +1,33 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
declare -r EXIT_SUCCESS="0"
|
||||
|
||||
mkdir -p /var/sonic
|
||||
echo "# Config files managed by sonic-config-engine" > /var/sonic/config_status
|
||||
|
||||
# If this platform has synchronization script, run it
|
||||
if [ -e /usr/share/sonic/platform/platform_wait ]; then
|
||||
/usr/share/sonic/platform/platform_wait
|
||||
EXIT_CODE="$?"
|
||||
if [ "${EXIT_CODE}" != "${EXIT_SUCCESS}" ]; then
|
||||
supervisorctl shutdown
|
||||
exit "${EXIT_CODE}"
|
||||
fi
|
||||
fi
|
||||
|
||||
# If the sonic-platform package is not installed, try to install it
|
||||
pip show sonic-platform > /dev/null 2>&1
|
||||
if [ $? -ne 0 ]; then
|
||||
SONIC_PLATFORM_WHEEL="/usr/share/sonic/platform/sonic_platform-1.0-py2-none-any.whl"
|
||||
echo "sonic-platform package not installed, attempting to install..."
|
||||
if [ -e ${SONIC_PLATFORM_WHEEL} ]; then
|
||||
pip install ${SONIC_PLATFORM_WHEEL}
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "Successfully installed ${SONIC_PLATFORM_WHEEL}"
|
||||
else
|
||||
echo "Error: Failed to install ${SONIC_PLATFORM_WHEEL}"
|
||||
fi
|
||||
else
|
||||
echo "Error: Unable to locate ${SONIC_PLATFORM_WHEEL}"
|
||||
fi
|
||||
fi
|
@ -1,81 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
declare -r EXIT_SUCCESS="0"
|
||||
|
||||
mkdir -p /var/sonic
|
||||
echo "# Config files managed by sonic-config-engine" > /var/sonic/config_status
|
||||
|
||||
rm -f /var/run/rsyslogd.pid
|
||||
|
||||
supervisorctl start rsyslogd
|
||||
|
||||
# If this platform has synchronization script, run it
|
||||
if [ -e /usr/share/sonic/platform/platform_wait ]; then
|
||||
/usr/share/sonic/platform/platform_wait
|
||||
EXIT_CODE="$?"
|
||||
if [ "${EXIT_CODE}" != "${EXIT_SUCCESS}" ]; then
|
||||
supervisorctl shutdown
|
||||
exit "${EXIT_CODE}"
|
||||
fi
|
||||
fi
|
||||
|
||||
{% if not skip_sensors %}
|
||||
# If this platform has an lm-sensors config file, copy it to it's proper place
|
||||
# and start lm-sensors
|
||||
if [ -e /usr/share/sonic/platform/sensors.conf ]; then
|
||||
mkdir -p /etc/sensors.d
|
||||
/bin/cp -f /usr/share/sonic/platform/sensors.conf /etc/sensors.d/
|
||||
supervisorctl start lm-sensors
|
||||
fi
|
||||
{% endif %}
|
||||
|
||||
{% if not skip_fancontrol %}
|
||||
# If this platform has a fancontrol config file, copy it to it's proper place
|
||||
# and start fancontrol
|
||||
if [ -e /usr/share/sonic/platform/fancontrol ]; then
|
||||
# Remove stale pid file if it exists
|
||||
rm -f /var/run/fancontrol.pid
|
||||
|
||||
/bin/cp -f /usr/share/sonic/platform/fancontrol /etc/
|
||||
supervisorctl start fancontrol
|
||||
fi
|
||||
{% endif %}
|
||||
|
||||
|
||||
# If the sonic-platform package is not installed, try to install it
|
||||
pip show sonic-platform > /dev/null 2>&1
|
||||
if [ $? -ne 0 ]; then
|
||||
SONIC_PLATFORM_WHEEL="/usr/share/sonic/platform/sonic_platform-1.0-py2-none-any.whl"
|
||||
echo "sonic-platform package not installed, attempting to install..."
|
||||
if [ -e ${SONIC_PLATFORM_WHEEL} ]; then
|
||||
pip install ${SONIC_PLATFORM_WHEEL}
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "Successfully installed ${SONIC_PLATFORM_WHEEL}"
|
||||
else
|
||||
echo "Error: Failed to install ${SONIC_PLATFORM_WHEEL}"
|
||||
fi
|
||||
else
|
||||
echo "Error: Unable to locate ${SONIC_PLATFORM_WHEEL}"
|
||||
fi
|
||||
fi
|
||||
|
||||
{% if not skip_ledd %}
|
||||
supervisorctl start ledd
|
||||
{% endif %}
|
||||
|
||||
{% if not skip_xcvrd %}
|
||||
supervisorctl start xcvrd
|
||||
{% endif %}
|
||||
|
||||
{% if not skip_psud %}
|
||||
supervisorctl start psud
|
||||
{% endif %}
|
||||
|
||||
{% if not skip_syseepromd %}
|
||||
supervisorctl start syseepromd
|
||||
{% endif %}
|
||||
|
||||
{% if not skip_thermalctld %}
|
||||
supervisorctl start thermalctld
|
||||
{% endif %}
|
||||
|
Loading…
Reference in New Issue
Block a user