Merge swss and syncd into single service (#334)

Current implementation of swss and syncd causes a lot
of problems in terms of dependencies and synchronization.
Instead of handling them in separate services, we now
start and stop them both as a single entity.

Signed-off-by: marian-pritsak <marianp@mellanox.com>
This commit is contained in:
Marian Pritsak 2017-03-01 20:57:35 +02:00 committed by lguohan
parent 73fb59c52c
commit a8776033bf
4 changed files with 34 additions and 37 deletions

View File

@ -184,8 +184,10 @@ sudo chroot $FILESYSTEM_ROOT service docker stop
sudo cp {{script}} $FILESYSTEM_ROOT/usr/bin/
{% endfor %}
{% for service in installer_services.split(' ') -%}
sudo cp {{service}} $FILESYSTEM_ROOT/etc/systemd/system/
sudo LANG=C chroot $FILESYSTEM_ROOT systemctl enable {{service}}
if [ -f {{service}} ]; then
sudo cp {{service}} $FILESYSTEM_ROOT/etc/systemd/system/
sudo LANG=C chroot $FILESYSTEM_ROOT systemctl enable {{service}}
fi
{% endfor %}
sudo LANG=C chroot $FILESYSTEM_ROOT fuser -km /sys || true
sudo LANG=C chroot $FILESYSTEM_ROOT umount -lf /sys

View File

@ -1,18 +1,40 @@
[Unit]
Description=switch state service container
Description=switch state service
Requires=database.service
After=database.service
[Service]
User={{ sonicadmin_user }}
# Wait for redis server start before database clean
ExecStartPre=/bin/bash -c "while true; do if [ \"$(/usr/bin/docker exec database redis-cli ping)\" == \"PONG\" ]; then break; fi; 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
ExecStart=/usr/bin/{{docker_container_name}}.sh start
{% if sonic_hwsku == 'ACS-MSN2700' %}
ExecStartPre=/etc/init.d/sxdkernel start
ExecStartPre=/usr/bin/mst start
ExecStartPre=/etc/mlnx/msn2700 start
{% elif sonic_hwsku == 'AS7512' %}
ExecStartPre=-/etc/init.d/xpnet.sh stop
ExecStartPre=/etc/init.d/xpnet.sh start
{% endif %}
# systemd allows only one parent process within service,
# so we spawn both dockers from single bash parent
ExecStart=/bin/bash -c "/usr/bin/{{docker_container_name}}.sh start & /usr/bin/syncd.sh start & wait -n 0"
ExecStop=/usr/bin/{{docker_container_name}}.sh stop
ExecStopPost=/usr/bin/syncd.sh stop
{% if sonic_hwsku == 'ACS-MSN2700' %}
ExecStopPost=/etc/mlnx/msn2700 stop
ExecStopPost=/etc/init.d/sxdkernel stop
ExecStopPost=/usr/bin/mst stop
{% elif sonic_hwsku == 'AS7512' %}
ExecStopPost=/etc/init.d/xpnet.sh stop
ExecStopPost=/etc/init.d/xpnet.sh start
{% endif %}
[Install]
WantedBy=multi-user.target

View File

@ -1,29 +0,0 @@
[Unit]
Description=syncd container
Requires=database.service
After=database.service
[Service]
User=root
{% if sonic_hwsku == 'ACS-MSN2700' %}
ExecStartPre=/etc/init.d/sxdkernel start
ExecStartPre=/usr/bin/mst start
ExecStartPre=/etc/mlnx/msn2700 start
{% elif sonic_hwsku == 'AS7512' %}
ExecStartPre=-/etc/init.d/xpnet.sh stop
ExecStartPre=/etc/init.d/xpnet.sh start
{% endif %}
ExecStart=/usr/bin/{{docker_container_name}}.sh start
ExecStop=/usr/bin/{{docker_container_name}}.sh stop
{% if sonic_hwsku == 'ACS-MSN2700' %}
ExecStopPost=/etc/mlnx/msn2700 stop
ExecStopPost=/etc/init.d/sxdkernel stop
ExecStopPost=/usr/bin/mst stop
{% elif sonic_hwsku == 'AS7512' %}
ExecStopPost=/etc/init.d/xpnet.sh stop
ExecStopPost=/etc/init.d/xpnet.sh start
{% endif %}
Restart=always
[Install]
WantedBy=multi-user.target

View File

@ -322,7 +322,9 @@ $(addprefix $(TARGET_PATH)/, $(SONIC_INSTALLERS)) : $(TARGET_PATH)/% : .platform
export docker_container_name="$($(docker)_CONTAINER_NAME)"
export docker_image_run_opt="$($(docker)_RUN_OPT)"
j2 files/build_templates/docker_image_ctl.j2 > $($(docker)_CONTAINER_NAME).sh
j2 files/build_templates/$($(docker)_CONTAINER_NAME).service.j2 > $($(docker)_CONTAINER_NAME).service
if [ -f files/build_templates/$($(docker)_CONTAINER_NAME).service.j2 ]; then
j2 files/build_templates/$($(docker)_CONTAINER_NAME).service.j2 > $($(docker)_CONTAINER_NAME).service
fi
chmod +x $($(docker)_CONTAINER_NAME).sh
)
@ -342,8 +344,8 @@ $(addprefix $(TARGET_PATH)/, $(SONIC_INSTALLERS)) : $(TARGET_PATH)/% : .platform
TARGET_MACHINE=$($*_MACHINE) IMAGE_TYPE=$($*_IMAGE_TYPE) DEBUG_BUILD=$(DEBUG_BUILD) ./build_image.sh $(LOG)
$(foreach docker, $($*_DOCKERS), \
rm $($(docker)_CONTAINER_NAME).sh
rm $($(docker)_CONTAINER_NAME).service
rm -f $($(docker)_CONTAINER_NAME).sh
rm -f $($(docker)_CONTAINER_NAME).service
)
$(if $($*_DOCKERS),