Notify systemd that this process has started

def notify_systemd():
    '''
    Notify systemd that this process has started
    '''
    try:
        import systemd.daemon
    except ImportError:
        if salt.utils.path.which('systemd-notify') \
                and systemd_notify_call('--booted'):
            # Notify systemd synchronously
            notify_socket = os.getenv('NOTIFY_SOCKET')
            if notify_socket:
                # Handle abstract namespace socket
                if notify_socket.startswith('@'):
                    notify_socket = '\0{0}'.format(notify_socket[1:])
                try:
                    sock = socket.socket(socket.AF_UNIX, socket.SOCK_DGRAM)
                    sock.connect(notify_socket)
                    sock.sendall('READY=1'.encode())
                    sock.close()
                except socket.error:
                    return systemd_notify_call('--ready')
                return True
        return False

    if systemd.daemon.booted():
        try:
            return systemd.daemon.notify('READY=1')
        except SystemError:
            # Daemon was not started by systemd
            pass