Restart the named service. This issues a stop command followed by a start.

    Args:
        name: The name of the service to restart.

            .. note::
                If the name passed is ``salt-minion`` a scheduled task is
                created and executed to restart the salt-minion service.

        timeout (int):
            The time in seconds to wait for the service to stop and start before
            returning. Default is 90 seconds

            .. note::
                The timeout is cumulative meaning it is applied to the stop and
                then to the start command. A timeout of 90 could take up to 180
                seconds if the service is long in stopping and starting

            .. versionadded:: 2017.7.9,2018.3.4

        with_deps (bool):
            If enabled restart the given service and the services
            the current service depends on.

        with_parents (bool):
            If enabled and in case other running services depend on the to be
            restarted service, this flag indicates that those other services
            will be restarted as well.
            If disabled, the service restart will fail in case other running
            services depend on the to be restarted service.

    Returns:
        bool: ``True`` if successful, otherwise ``False``

    CLI Example:

    .. code-block:: bash

        salt '*' service.restart <service name>

def restart(name, timeout=90, with_deps=False, with_parents=False):
    '''
    Restart the named service. This issues a stop command followed by a start.

    Args:
        name: The name of the service to restart.

            .. note::
                If the name passed is ``salt-minion`` a scheduled task is
                created and executed to restart the salt-minion service.

        timeout (int):
            The time in seconds to wait for the service to stop and start before
            returning. Default is 90 seconds

            .. note::
                The timeout is cumulative meaning it is applied to the stop and
                then to the start command. A timeout of 90 could take up to 180
                seconds if the service is long in stopping and starting

            .. versionadded:: 2017.7.9,2018.3.4

        with_deps (bool):
            If enabled restart the given service and the services
            the current service depends on.

        with_parents (bool):
            If enabled and in case other running services depend on the to be
            restarted service, this flag indicates that those other services
            will be restarted as well.
            If disabled, the service restart will fail in case other running
            services depend on the to be restarted service.

    Returns:
        bool: ``True`` if successful, otherwise ``False``

    CLI Example:

    .. code-block:: bash

        salt '*' service.restart <service name>
    '''
    if 'salt-minion' in name:
        create_win_salt_restart_task()
        return execute_salt_restart_task()

    ret = set()
    ret.add(stop(name=name, timeout=timeout, with_deps=with_deps, with_parents=with_parents))
    ret.add(start(name=name, timeout=timeout, with_deps=with_deps, with_parents=with_parents))
    return False not in ret