sonic-buildimage/files/build_templates/swss.service.j2

57 lines
2.1 KiB
Django/Jinja

[Unit]
Description=switch state service
Requires=database.service updategraph.service
{% if sonic_asic_platform == 'broadcom' %}
Requires=opennsl-modules-4.9.0-3-amd64.service
{% elif sonic_asic_platform == 'nephos' %}
Requires=nps-modules-4.9.0-3-amd64.service
{% endif %}
After=database.service updategraph.service
After=interfaces-config.service
{% if sonic_asic_platform == 'broadcom' %}
After=opennsl-modules-4.9.0-3-amd64.service
{% elif sonic_asic_platform == 'nephos' %}
After=nps-modules-4.9.0-3-amd64.service
{% endif %}
[Service]
User=root
# Wait for redis server start before database clean
ExecStartPre=/bin/bash -c 'until [[ $(/usr/bin/docker exec database redis-cli ping | grep -c PONG) -gt 0 ]]; do sleep 1; done'
ExecStartPre=/usr/bin/docker exec database redis-cli -n 0 FLUSHDB
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 "/usr/share/sonic/device/$(sonic-cfggen -H -v DEVICE_METADATA.localhost.platform)/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 "/usr/share/sonic/device/$(sonic-cfggen -H -v DEVICE_METADATA.localhost.platform)/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]
WantedBy=multi-user.target