diff --git a/files/build_templates/init_cfg.json.j2 b/files/build_templates/init_cfg.json.j2 index 31249abd582..b51aaf2f0c1 100644 --- a/files/build_templates/init_cfg.json.j2 +++ b/files/build_templates/init_cfg.json.j2 @@ -30,6 +30,7 @@ {%- set features = [("bgp", "enabled", false, "enabled"), ("database", "always_enabled", false, "always_enabled"), ("lldp", "enabled", true, "enabled"), + ("pmon", "enabled", true, "enabled"), ("pmon", "enabled", false, "enabled"), ("radv", "enabled", false, "enabled"), ("snmp", "enabled", true, "enabled"), diff --git a/files/build_templates/pmon.service.j2 b/files/build_templates/pmon.service.j2 index 2cc28b1fc13..2e7ebca1c72 100644 --- a/files/build_templates/pmon.service.j2 +++ b/files/build_templates/pmon.service.j2 @@ -17,6 +17,3 @@ ExecStartPre=/usr/bin/{{docker_container_name}}.sh start ExecStart=/usr/bin/{{docker_container_name}}.sh wait ExecStop=/usr/bin/{{docker_container_name}}.sh stop RestartSec=30 - -[Install] -WantedBy=sonic.target diff --git a/files/build_templates/pmon.timer b/files/build_templates/pmon.timer new file mode 100644 index 00000000000..2993051607e --- /dev/null +++ b/files/build_templates/pmon.timer @@ -0,0 +1,12 @@ +[Unit] +# This delay is for fast/warm reboot performance +Description=Delays pmon docker until SONiC has started +PartOf=pmon.service + +[Timer] +OnUnitActiveSec=0 sec +OnBootSec=1min 30 sec +Unit=pmon.service + +[Install] +WantedBy=timers.target sonic.target sonic-delayed.target diff --git a/files/build_templates/sonic_debian_extension.j2 b/files/build_templates/sonic_debian_extension.j2 index 0cdabf7cfaa..516df5fd224 100644 --- a/files/build_templates/sonic_debian_extension.j2 +++ b/files/build_templates/sonic_debian_extension.j2 @@ -831,6 +831,9 @@ sudo cp $BUILD_TEMPLATES/mgmt-framework.timer $FILESYSTEM_ROOT_USR_LIB_SYSTEMD_S echo "mgmt-framework.timer" | sudo tee -a $GENERATED_SERVICE_FILE {% endif %} +sudo cp $BUILD_TEMPLATES/pmon.timer $FILESYSTEM_ROOT_USR_LIB_SYSTEMD_SYSTEM +echo "pmon.timer" | sudo tee -a $GENERATED_SERVICE_FILE + sudo cp $BUILD_TEMPLATES/sonic.target $FILESYSTEM_ROOT_USR_LIB_SYSTEMD_SYSTEM sudo LANG=C chroot $FILESYSTEM_ROOT systemctl enable sonic.target diff --git a/files/scripts/syncd.sh b/files/scripts/syncd.sh index 83f99d70d7e..628609e0a5f 100755 --- a/files/scripts/syncd.sh +++ b/files/scripts/syncd.sh @@ -45,10 +45,15 @@ function startplatform() { function waitplatform() { + BOOT_TYPE=`getBootType` if [[ x"$sonic_asic_platform" == x"mellanox" ]]; then - debug "Starting pmon service..." - /bin/systemctl start pmon - debug "Started pmon service" + if [[ x"$BOOT_TYPE" = @(x"fast"|x"warm"|x"fastfast") ]]; then + debug "PMON service is delayed by a timer for better fast/warm boot performance" + else + debug "Starting pmon service..." + /bin/systemctl start pmon + debug "Started pmon service" + fi fi if [[ x"$BOOT_TYPE" = @(x"fast"|x"warm"|x"fastfast") ]]; then debug "LLDP service is delayed by a timer for better fast/warm boot performance"