Skip to content

Commit

Permalink
Add thermal control support for SONiC (sonic-net#3949) (#179)
Browse files Browse the repository at this point in the history
* Add thermalctl to pmon docker
 * Still use original commit message for reference

Co-authored-by: Junchao-Mellanox <57339448+Junchao-Mellanox@users.noreply.github.com>
  • Loading branch information
pphuchar and Junchao-Mellanox committed May 21, 2020
1 parent 9e03c2a commit 84382d1
Show file tree
Hide file tree
Showing 5 changed files with 72 additions and 1 deletion.
11 changes: 11 additions & 0 deletions dockers/docker-platform-monitor/docker-pmon.supervisord.conf.j2
Original file line number Diff line number Diff line change
Expand Up @@ -91,3 +91,14 @@ stdout_logfile=syslog
stderr_logfile=syslog
startsecs=10
{% endif %}

{% if not skip_thermalctld %}
[program:thermalctld]
command=/usr/bin/thermalctld
priority=9
autostart=false
autorestart=true
stdout_logfile=syslog
stderr_logfile=syslog
startsecs=0
{% endif %}
4 changes: 4 additions & 0 deletions dockers/docker-platform-monitor/start.sh.j2
Original file line number Diff line number Diff line change
Expand Up @@ -75,3 +75,7 @@ supervisorctl start psud
supervisorctl start syseepromd
{% endif %}

{% if not skip_thermalctld %}
supervisorctl start thermalctld
{% endif %}

2 changes: 1 addition & 1 deletion rules/docker-platform-monitor.mk
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ $(DOCKER_PLATFORM_MONITOR)_DEPENDS += $(LIBSENSORS) $(LM_SENSORS) $(FANCONTROL)
ifeq ($(CONFIGURED_PLATFORM),barefoot)
$(DOCKER_PLATFORM_MONITOR)_DEPENDS += $(PYTHON_THRIFT)
endif
$(DOCKER_PLATFORM_MONITOR)_PYTHON_DEBS += $(SONIC_LEDD) $(SONIC_XCVRD) $(SONIC_PSUD) $(SONIC_SYSEEPROMD)
$(DOCKER_PLATFORM_MONITOR)_PYTHON_DEBS += $(SONIC_LEDD) $(SONIC_XCVRD) $(SONIC_PSUD) $(SONIC_SYSEEPROMD) $(SONIC_THERMALCTLD)
$(DOCKER_PLATFORM_MONITOR)_PYTHON_WHEELS += $(SONIC_PLATFORM_COMMON_PY2)
$(DOCKER_PLATFORM_MONITOR)_PYTHON_WHEELS += $(SWSSSDK_PY2)
$(DOCKER_PLATFORM_MONITOR)_PYTHON_WHEELS += $(SONIC_PLATFORM_API_PY2)
Expand Down
6 changes: 6 additions & 0 deletions rules/sonic-thermalctld.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# sonic-thermalctld (SONiC Thermal control daemon) Debian package

SONIC_THERMALCTLD = python-sonic-thermalctld_1.0-1_all.deb
$(SONIC_THERMALCTLD)_SRC_PATH = $(SRC_PATH)/sonic-platform-daemons/sonic-thermalctld
$(SONIC_THERMALCTLD)_WHEEL_DEPENDS = $(SONIC_DAEMON_BASE_PY2)
SONIC_PYTHON_STDEB_DEBS += $(SONIC_THERMALCTLD)
50 changes: 50 additions & 0 deletions src/sonic-daemon-base/sonic_daemon_base/task_base.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import multiprocessing
import os
import signal
import threading


#
# ProcessTaskBase =====================================================================
#
class ProcessTaskBase(object): # TODO: put this class to swss-platform-common
def __init__(self):
self.task_process = None
self.task_stopping_event = multiprocessing.Event()

def task_worker(self):
pass

def task_run(self):
if self.task_stopping_event.is_set():
return

self.task_process = multiprocessing.Process(target=self.task_worker)
self.task_process.start()

def task_stop(self):
self.task_stopping_event.set()
os.kill(self.task_process.pid, signal.SIGKILL)


#
# ThreadTaskBase =====================================================================
#
class ThreadTaskBase(object): # TODO: put this class to swss-platform-common;
def __init__(self):
self.task_thread = None
self.task_stopping_event = threading.Event()

def task_worker(self):
pass

def task_run(self):
if self.task_stopping_event.is_set():
return

self.task_thread = threading.Thread(target=self.task_worker)
self.task_thread.start()

def task_stop(self):
self.task_stopping_event.set()
self.task_thread.join()

0 comments on commit 84382d1

Please sign in to comment.