Skip to content

Commit 84382d1

Browse files
Add thermal control support for SONiC (sonic-net#3949) (#179)
* Add thermalctl to pmon docker * Still use original commit message for reference Co-authored-by: Junchao-Mellanox <[email protected]>
1 parent 9e03c2a commit 84382d1

File tree

5 files changed

+72
-1
lines changed

5 files changed

+72
-1
lines changed

dockers/docker-platform-monitor/docker-pmon.supervisord.conf.j2

+11
Original file line numberDiff line numberDiff line change
@@ -91,3 +91,14 @@ stdout_logfile=syslog
9191
stderr_logfile=syslog
9292
startsecs=10
9393
{% endif %}
94+
95+
{% if not skip_thermalctld %}
96+
[program:thermalctld]
97+
command=/usr/bin/thermalctld
98+
priority=9
99+
autostart=false
100+
autorestart=true
101+
stdout_logfile=syslog
102+
stderr_logfile=syslog
103+
startsecs=0
104+
{% endif %}

dockers/docker-platform-monitor/start.sh.j2

+4
Original file line numberDiff line numberDiff line change
@@ -75,3 +75,7 @@ supervisorctl start psud
7575
supervisorctl start syseepromd
7676
{% endif %}
7777

78+
{% if not skip_thermalctld %}
79+
supervisorctl start thermalctld
80+
{% endif %}
81+

rules/docker-platform-monitor.mk

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ $(DOCKER_PLATFORM_MONITOR)_DEPENDS += $(LIBSENSORS) $(LM_SENSORS) $(FANCONTROL)
1010
ifeq ($(CONFIGURED_PLATFORM),barefoot)
1111
$(DOCKER_PLATFORM_MONITOR)_DEPENDS += $(PYTHON_THRIFT)
1212
endif
13-
$(DOCKER_PLATFORM_MONITOR)_PYTHON_DEBS += $(SONIC_LEDD) $(SONIC_XCVRD) $(SONIC_PSUD) $(SONIC_SYSEEPROMD)
13+
$(DOCKER_PLATFORM_MONITOR)_PYTHON_DEBS += $(SONIC_LEDD) $(SONIC_XCVRD) $(SONIC_PSUD) $(SONIC_SYSEEPROMD) $(SONIC_THERMALCTLD)
1414
$(DOCKER_PLATFORM_MONITOR)_PYTHON_WHEELS += $(SONIC_PLATFORM_COMMON_PY2)
1515
$(DOCKER_PLATFORM_MONITOR)_PYTHON_WHEELS += $(SWSSSDK_PY2)
1616
$(DOCKER_PLATFORM_MONITOR)_PYTHON_WHEELS += $(SONIC_PLATFORM_API_PY2)

rules/sonic-thermalctld.mk

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# sonic-thermalctld (SONiC Thermal control daemon) Debian package
2+
3+
SONIC_THERMALCTLD = python-sonic-thermalctld_1.0-1_all.deb
4+
$(SONIC_THERMALCTLD)_SRC_PATH = $(SRC_PATH)/sonic-platform-daemons/sonic-thermalctld
5+
$(SONIC_THERMALCTLD)_WHEEL_DEPENDS = $(SONIC_DAEMON_BASE_PY2)
6+
SONIC_PYTHON_STDEB_DEBS += $(SONIC_THERMALCTLD)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
import multiprocessing
2+
import os
3+
import signal
4+
import threading
5+
6+
7+
#
8+
# ProcessTaskBase =====================================================================
9+
#
10+
class ProcessTaskBase(object): # TODO: put this class to swss-platform-common
11+
def __init__(self):
12+
self.task_process = None
13+
self.task_stopping_event = multiprocessing.Event()
14+
15+
def task_worker(self):
16+
pass
17+
18+
def task_run(self):
19+
if self.task_stopping_event.is_set():
20+
return
21+
22+
self.task_process = multiprocessing.Process(target=self.task_worker)
23+
self.task_process.start()
24+
25+
def task_stop(self):
26+
self.task_stopping_event.set()
27+
os.kill(self.task_process.pid, signal.SIGKILL)
28+
29+
30+
#
31+
# ThreadTaskBase =====================================================================
32+
#
33+
class ThreadTaskBase(object): # TODO: put this class to swss-platform-common;
34+
def __init__(self):
35+
self.task_thread = None
36+
self.task_stopping_event = threading.Event()
37+
38+
def task_worker(self):
39+
pass
40+
41+
def task_run(self):
42+
if self.task_stopping_event.is_set():
43+
return
44+
45+
self.task_thread = threading.Thread(target=self.task_worker)
46+
self.task_thread.start()
47+
48+
def task_stop(self):
49+
self.task_stopping_event.set()
50+
self.task_thread.join()

0 commit comments

Comments
 (0)