Skip to content

Commit

Permalink
[Pmon] dynamically load pmon daemons (#2654)
Browse files Browse the repository at this point in the history
* dynamically load pmon daemons
  • Loading branch information
keboliu authored and lguohan committed Mar 22, 2019
1 parent 60968cf commit 84b46bb
Show file tree
Hide file tree
Showing 12 changed files with 44 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"skip_ledd": true
}

6 changes: 3 additions & 3 deletions dockers/docker-platform-monitor/Dockerfile.j2
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ RUN apt-get autoclean -y
RUN apt-get autoremove -y
RUN rm -rf /debs /python-wheels ~/.cache

COPY ["start.sh", "lm-sensors.sh", "/usr/bin/"]
COPY ["supervisord.conf", "/etc/supervisor/conf.d/"]
COPY ["docker_init.sh", "lm-sensors.sh", "/usr/bin/"]
COPY ["docker-pmon.supervisord.conf.j2", "start.sh.j2", "/usr/share/sonic/templates/"]

ENTRYPOINT ["/usr/bin/supervisord"]
ENTRYPOINT ["/usr/bin/docker_init.sh"]
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ autorestart=false
stdout_logfile=syslog
stderr_logfile=syslog

{% if not skip_ledd %}
[program:ledd]
command=/usr/bin/ledd
priority=5
Expand All @@ -45,7 +46,9 @@ autorestart=false
stdout_logfile=syslog
stderr_logfile=syslog
startsecs=0
{% endif %}

{% if not skip_xcvrd %}
[program:xcvrd]
command=/usr/bin/xcvrd
priority=6
Expand All @@ -54,7 +57,9 @@ autorestart=false
stdout_logfile=syslog
stderr_logfile=syslog
startsecs=0
{% endif %}

{% if not skip_psud %}
[program:psud]
command=/usr/bin/psud
priority=7
Expand All @@ -63,4 +68,4 @@ autorestart=false
stdout_logfile=syslog
stderr_logfile=syslog
startsecs=0

{% endif %}
18 changes: 18 additions & 0 deletions dockers/docker-platform-monitor/docker_init.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/usr/bin/env bash

# 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 ];
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
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
fi

exec /usr/bin/supervisord

6 changes: 6 additions & 0 deletions dockers/docker-platform-monitor/start.sh → dockers/docker-platform-monitor/start.sh.j2
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,14 @@ if [ -e /usr/share/sonic/platform/fancontrol ]; then
supervisorctl start fancontrol
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 %}

0 comments on commit 84b46bb

Please sign in to comment.