[swss]: simplify swss systemd service file (#1965)
move the swss service start/stop logic into /usr/local/bin/swss.sh Signed-off-by: Guohan Lu <gulv@microsoft.com>
This commit is contained in:
parent
ada11409b2
commit
80c6453731
@ -27,6 +27,7 @@ set -x -e
|
|||||||
. functions.sh
|
. functions.sh
|
||||||
BUILD_TEMPLATES=files/build_templates
|
BUILD_TEMPLATES=files/build_templates
|
||||||
IMAGE_CONFIGS=files/image_config
|
IMAGE_CONFIGS=files/image_config
|
||||||
|
SCRIPTS_DIR=files/scripts
|
||||||
|
|
||||||
# Define target fold macro
|
# Define target fold macro
|
||||||
FILESYSTEM_ROOT_USR="$FILESYSTEM_ROOT/usr"
|
FILESYSTEM_ROOT_USR="$FILESYSTEM_ROOT/usr"
|
||||||
@ -292,6 +293,9 @@ sudo LANG=C chroot $FILESYSTEM_ROOT fuser -km /sys || true
|
|||||||
sudo LANG=C chroot $FILESYSTEM_ROOT umount -lf /sys
|
sudo LANG=C chroot $FILESYSTEM_ROOT umount -lf /sys
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
|
# Copy swss service script
|
||||||
|
sudo LANG=C cp $SCRIPTS_DIR/swss.sh $FILESYSTEM_ROOT/usr/local/bin/swss.sh
|
||||||
|
|
||||||
# Copy systemd timer configuration
|
# Copy systemd timer configuration
|
||||||
# It implements delayed start of services
|
# It implements delayed start of services
|
||||||
sudo cp $BUILD_TEMPLATES/snmp.timer $FILESYSTEM_ROOT/etc/systemd/system/
|
sudo cp $BUILD_TEMPLATES/snmp.timer $FILESYSTEM_ROOT/etc/systemd/system/
|
||||||
|
@ -16,41 +16,9 @@ After=nps-modules-4.9.0-7-amd64.service
|
|||||||
|
|
||||||
[Service]
|
[Service]
|
||||||
User=root
|
User=root
|
||||||
# Wait for redis server start before database clean
|
Environment=sonic_asic_platform={{ sonic_asic_platform }}
|
||||||
ExecStartPre=/bin/bash -c 'until [[ $(/usr/bin/docker exec database redis-cli ping | grep -c PONG) -gt 0 ]]; do sleep 1; done'
|
ExecStart=/usr/local/bin/swss.sh start
|
||||||
ExecStartPre=/usr/bin/docker exec database redis-cli -n 0 FLUSHDB
|
ExecStop=/usr/local/bin/swss.sh stop
|
||||||
ExecStartPre=/usr/bin/docker exec database redis-cli -n 1 FLUSHDB
|
|
||||||
ExecStartPre=/usr/bin/docker exec database redis-cli -n 2 FLUSHDB
|
|
||||||
ExecStartPre=/usr/bin/docker exec database redis-cli -n 5 FLUSHDB
|
|
||||||
ExecStartPre=/usr/bin/docker exec database redis-cli -n 6 FLUSHDB
|
|
||||||
|
|
||||||
{% if sonic_asic_platform == 'mellanox' %}
|
|
||||||
Environment=FAST_BOOT=1
|
|
||||||
TimeoutStartSec=3min
|
|
||||||
ExecStartPre=/usr/bin/mst start
|
|
||||||
ExecStartPre=/usr/bin/mlnx-fw-upgrade.sh
|
|
||||||
ExecStartPre=/etc/init.d/sxdkernel start
|
|
||||||
ExecStartPre=/sbin/modprobe i2c-dev
|
|
||||||
ExecStartPre=/bin/bash -c "/etc/mlnx/mlnx-hw-management start"
|
|
||||||
{% elif sonic_asic_platform == 'cavium' %}
|
|
||||||
ExecStartPre=/etc/init.d/xpnet.sh start
|
|
||||||
{% endif %}
|
|
||||||
|
|
||||||
ExecStartPre=/usr/bin/{{docker_container_name}}.sh start
|
|
||||||
ExecStartPre=/usr/bin/syncd.sh start
|
|
||||||
ExecStart=/usr/bin/{{docker_container_name}}.sh attach
|
|
||||||
|
|
||||||
ExecStop=/usr/bin/{{docker_container_name}}.sh stop
|
|
||||||
ExecStopPost=/usr/bin/syncd.sh stop
|
|
||||||
|
|
||||||
{% if sonic_asic_platform == 'mellanox' %}
|
|
||||||
ExecStopPost=/bin/bash -c "/etc/mlnx/mlnx-hw-management stop"
|
|
||||||
ExecStopPost=/etc/init.d/sxdkernel stop
|
|
||||||
ExecStopPost=/usr/bin/mst stop
|
|
||||||
{% elif sonic_asic_platform == 'cavium' %}
|
|
||||||
ExecStopPost=/etc/init.d/xpnet.sh stop
|
|
||||||
ExecStopPost=/etc/init.d/xpnet.sh start
|
|
||||||
{% endif %}
|
|
||||||
|
|
||||||
[Install]
|
[Install]
|
||||||
WantedBy=multi-user.target
|
WantedBy=multi-user.target
|
||||||
|
57
files/scripts/swss.sh
Executable file
57
files/scripts/swss.sh
Executable file
@ -0,0 +1,57 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
start() {
|
||||||
|
# Wait for redis server start before database clean
|
||||||
|
until [[ $(/usr/bin/docker exec database redis-cli ping | grep -c PONG) -gt 0 ]];
|
||||||
|
do sleep 1;
|
||||||
|
done
|
||||||
|
|
||||||
|
# Flush DB
|
||||||
|
/usr/bin/docker exec database redis-cli -n 0 FLUSHDB
|
||||||
|
/usr/bin/docker exec database redis-cli -n 1 FLUSHDB
|
||||||
|
/usr/bin/docker exec database redis-cli -n 2 FLUSHDB
|
||||||
|
/usr/bin/docker exec database redis-cli -n 5 FLUSHDB
|
||||||
|
/usr/bin/docker exec database redis-cli -n 6 FLUSHDB
|
||||||
|
|
||||||
|
# platform specific tasks
|
||||||
|
if [ x$sonic_asic_platform == x'mellanox' ]; then
|
||||||
|
FAST_BOOT=1
|
||||||
|
/usr/bin/mst start
|
||||||
|
/usr/bin/mlnx-fw-upgrade.sh
|
||||||
|
/etc/init.d/sxdkernel start
|
||||||
|
/sbin/modprobe i2c-dev
|
||||||
|
/etc/mlnx/mlnx-hw-management start
|
||||||
|
elif [ x$sonic_asic_platform == x'cavium' ]; then
|
||||||
|
/etc/init.d/xpnet.sh start
|
||||||
|
fi
|
||||||
|
|
||||||
|
# start swss and syncd docker
|
||||||
|
/usr/bin/swss.sh start
|
||||||
|
/usr/bin/syncd.sh start
|
||||||
|
/usr/bin/swss.sh attach
|
||||||
|
}
|
||||||
|
|
||||||
|
stop() {
|
||||||
|
/usr/bin/swss.sh stop
|
||||||
|
/usr/bin/syncd.sh stop
|
||||||
|
|
||||||
|
# platform specific tasks
|
||||||
|
if [ x$sonic_asic_platform == x'mellanox' ]; then
|
||||||
|
/etc/mlnx/mlnx-hw-management stop
|
||||||
|
/etc/init.d/sxdkernel stop
|
||||||
|
/usr/bin/mst stop
|
||||||
|
elif [ x$sonic_asic_platform == x'cavium' ]; then
|
||||||
|
/etc/init.d/xpnet.sh stop
|
||||||
|
/etc/init.d/xpnet.sh start
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
case "$1" in
|
||||||
|
start|stop)
|
||||||
|
$1
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
echo "Usage: $0 {start|stop}"
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
|
esac
|
Loading…
Reference in New Issue
Block a user