From 88c5ea5627fe8f4142d844b35f6c3fc3a62dd59a Mon Sep 17 00:00:00 2001 From: Pavel Shirshov Date: Tue, 24 Jul 2018 12:15:10 -0700 Subject: [PATCH 1/2] Put all services for restart into a list --- config/main.py | 45 +++++++++++++++++++++++++++------------------ 1 file changed, 27 insertions(+), 18 deletions(-) diff --git a/config/main.py b/config/main.py index 6b53a1246c..f55123459e 100755 --- a/config/main.py +++ b/config/main.py @@ -140,26 +140,35 @@ def _abort_if_false(ctx, param, value): ctx.abort() def _stop_services(): - run_command("service dhcp_relay stop", display_cmd=True) - run_command("service swss stop", display_cmd=True) - run_command("service snmp stop", display_cmd=True) - run_command("service lldp stop", display_cmd=True) - run_command("service pmon stop", display_cmd=True) - run_command("service bgp stop", display_cmd=True) - run_command("service teamd stop", display_cmd=True) + services = [ + 'dhcp_relay', + 'swss', + 'snmp', + 'lldp', + 'pmon', + 'bgp', + 'teamd', + ] + for service in services: + run_command("service %s stop" % service, display_cmd=True) def _restart_services(): - run_command("service hostname-config restart", display_cmd=True) - run_command("service interfaces-config restart", display_cmd=True) - run_command("service ntp-config restart", display_cmd=True) - run_command("service rsyslog-config restart", display_cmd=True) - run_command("service swss restart", display_cmd=True) - run_command("service bgp restart", display_cmd=True) - run_command("service teamd restart", display_cmd=True) - run_command("service pmon restart", display_cmd=True) - run_command("service lldp restart", display_cmd=True) - run_command("service snmp restart", display_cmd=True) - run_command("service dhcp_relay restart", display_cmd=True) + services = [ + 'hostname-config', + 'interfaces-config', + 'ntp-config', + 'rsyslog-config', + 'swss', + 'bgp', + 'teamd', + 'pmon', + 'lldp', + 'snmp', + 'dhcp_relay', + ] + for service in services: + run_command("service %s restart" % service, display_cmd=True) + # This is our main entrypoint - the main 'config' command @click.group() From 7ebdb4c48f71d312f3887d84bb1ba421e83b1831 Mon Sep 17 00:00:00 2001 From: Pavel Shirshov Date: Tue, 24 Jul 2018 12:17:35 -0700 Subject: [PATCH 2/2] Use systemctl instead of service which is a wrapper around systemctl in Debian 8 and newer --- config/main.py | 4 ++-- config/mlnx.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/config/main.py b/config/main.py index f55123459e..9d65c3fb9b 100755 --- a/config/main.py +++ b/config/main.py @@ -150,7 +150,7 @@ def _stop_services(): 'teamd', ] for service in services: - run_command("service %s stop" % service, display_cmd=True) + run_command("systemctl stop %s" % service, display_cmd=True) def _restart_services(): services = [ @@ -167,7 +167,7 @@ def _restart_services(): 'dhcp_relay', ] for service in services: - run_command("service %s restart" % service, display_cmd=True) + run_command("systemctl restart %s" % service, display_cmd=True) # This is our main entrypoint - the main 'config' command diff --git a/config/mlnx.py b/config/mlnx.py index 01292cfb5a..1e47dea7ae 100644 --- a/config/mlnx.py +++ b/config/mlnx.py @@ -46,7 +46,7 @@ SNIFFER_CONF_FILE = '/etc/supervisor/conf.d/mlnx_sniffer.conf' # Command to restart swss service -COMMAND_RESTART_SWSS = 'service swss restart' +COMMAND_RESTART_SWSS = 'systemctl restart swss.service' # global variable SDK_SNIFFER_TARGET_FILE_NAME SDK_SNIFFER_TARGET_FILE_NAME = ''