Skip to content

Commit 2f3b541

Browse files
jlevequetiantianlv
authored andcommitted
[services] Ensure swss and syncd services start before dependent services (sonic-net#2634)
* [services] Ensure swss and syncd services start before dependent services * Add 'attach' functions to scripts which get installed to /usr/local/bin so that services only reference the one script each * Add 'After=swss.service' to syncd.service
1 parent 1d0206f commit 2f3b541

File tree

4 files changed

+15
-6
lines changed

4 files changed

+15
-6
lines changed

files/build_templates/swss.service.j2

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ Before=ntp-config.service
1313
[Service]
1414
User=root
1515
Environment=sonic_asic_platform={{ sonic_asic_platform }}
16-
ExecStart=/usr/local/bin/swss.sh start
16+
ExecStartPre=/usr/local/bin/swss.sh start
17+
ExecStart=/usr/local/bin/swss.sh attach
1718
ExecStop=/usr/local/bin/swss.sh stop
1819

1920
[Install]

files/build_templates/syncd.service.j2

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,14 @@ After=opennsl-modules-4.9.0-8-amd64.service
1313
{% elif sonic_asic_platform == 'nephos' %}
1414
After=nps-modules-4.9.0-8-amd64.service
1515
{% endif %}
16+
After=swss.service
1617
Before=ntp-config.service
1718

1819
[Service]
1920
User=root
2021
Environment=sonic_asic_platform={{ sonic_asic_platform }}
21-
ExecStart=/usr/local/bin/syncd.sh start
22+
ExecStartPre=/usr/local/bin/syncd.sh start
23+
ExecStart=/usr/local/bin/syncd.sh attach
2224
ExecStop=/usr/local/bin/syncd.sh stop
2325

2426
[Install]

files/scripts/swss.sh

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,9 @@ start() {
109109
if [[ x"$WARM_BOOT" != x"true" ]]; then
110110
/bin/systemctl start ${PEER}
111111
fi
112+
}
113+
114+
attach() {
112115
/usr/bin/${SERVICE}.sh attach
113116
}
114117

@@ -134,11 +137,11 @@ stop() {
134137
}
135138

136139
case "$1" in
137-
start|stop)
140+
start|attach|stop)
138141
$1
139142
;;
140143
*)
141-
echo "Usage: $0 {start|stop}"
144+
echo "Usage: $0 {start|attach|stop}"
142145
exit 1
143146
;;
144147
esac

files/scripts/syncd.sh

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,9 @@ start() {
117117
debug "Started ${SERVICE} service..."
118118

119119
unlock_service_state_change
120+
}
121+
122+
attach() {
120123
/usr/bin/${SERVICE}.sh attach
121124
}
122125

@@ -165,11 +168,11 @@ stop() {
165168
}
166169

167170
case "$1" in
168-
start|stop)
171+
start|attach|stop)
169172
$1
170173
;;
171174
*)
172-
echo "Usage: $0 {start|stop}"
175+
echo "Usage: $0 {start|attach|stop}"
173176
exit 1
174177
;;
175178
esac

0 commit comments

Comments
 (0)