Skip to content

Commit

Permalink
[services] Ensure swss and syncd services start before dependent serv…
Browse files Browse the repository at this point in the history
…ices (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
  • Loading branch information
jleveque authored and tiantianlv committed Apr 10, 2019
1 parent 1d0206f commit 2f3b541
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 6 deletions.
3 changes: 2 additions & 1 deletion files/build_templates/swss.service.j2
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ Before=ntp-config.service
[Service]
User=root
Environment=sonic_asic_platform={{ sonic_asic_platform }}
ExecStart=/usr/local/bin/swss.sh start
ExecStartPre=/usr/local/bin/swss.sh start
ExecStart=/usr/local/bin/swss.sh attach
ExecStop=/usr/local/bin/swss.sh stop

[Install]
Expand Down
4 changes: 3 additions & 1 deletion files/build_templates/syncd.service.j2
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,14 @@ After=opennsl-modules-4.9.0-8-amd64.service
{% elif sonic_asic_platform == 'nephos' %}
After=nps-modules-4.9.0-8-amd64.service
{% endif %}
After=swss.service
Before=ntp-config.service

[Service]
User=root
Environment=sonic_asic_platform={{ sonic_asic_platform }}
ExecStart=/usr/local/bin/syncd.sh start
ExecStartPre=/usr/local/bin/syncd.sh start
ExecStart=/usr/local/bin/syncd.sh attach
ExecStop=/usr/local/bin/syncd.sh stop

[Install]
Expand Down
7 changes: 5 additions & 2 deletions files/scripts/swss.sh
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,9 @@ start() {
if [[ x"$WARM_BOOT" != x"true" ]]; then
/bin/systemctl start ${PEER}
fi
}

attach() {
/usr/bin/${SERVICE}.sh attach
}

Expand All @@ -134,11 +137,11 @@ stop() {
}

case "$1" in
start|stop)
start|attach|stop)
$1
;;
*)
echo "Usage: $0 {start|stop}"
echo "Usage: $0 {start|attach|stop}"
exit 1
;;
esac
7 changes: 5 additions & 2 deletions files/scripts/syncd.sh
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,9 @@ start() {
debug "Started ${SERVICE} service..."

unlock_service_state_change
}

attach() {
/usr/bin/${SERVICE}.sh attach
}

Expand Down Expand Up @@ -165,11 +168,11 @@ stop() {
}

case "$1" in
start|stop)
start|attach|stop)
$1
;;
*)
echo "Usage: $0 {start|stop}"
echo "Usage: $0 {start|attach|stop}"
exit 1
;;
esac

0 comments on commit 2f3b541

Please sign in to comment.