2019-10-01 23:42:35 +02:00
|
|
|
#!/usr/bin/env python3
|
2015-09-28 19:57:40 +02:00
|
|
|
|
2019-10-01 23:42:35 +02:00
|
|
|
import os
|
|
|
|
import socket
|
|
|
|
import sys
|
|
|
|
from urllib.parse import urlsplit
|
|
|
|
|
|
|
|
BASE_DIR = os.path.join(os.path.dirname(os.path.abspath(__file__)), "../..")
|
|
|
|
sys.path.append(BASE_DIR)
|
|
|
|
|
|
|
|
import scripts.lib.setup_path_on_import
|
|
|
|
from zproject import settings
|
|
|
|
|
|
|
|
url = urlsplit("//" + settings.MEMCACHED_LOCATION)
|
2019-11-13 10:06:02 +01:00
|
|
|
assert url.port is not None
|
2019-10-01 23:42:35 +02:00
|
|
|
|
|
|
|
print("Flushing memcached...")
|
|
|
|
with socket.create_connection((url.hostname, url.port)) as f:
|
|
|
|
f.sendall(b"flush_all\r\n")
|
|
|
|
response = b""
|
|
|
|
while b"\n" not in response:
|
|
|
|
response += f.recv(4096)
|
|
|
|
if response != b"OK\r\n":
|
|
|
|
print(response, file=sys.stderr)
|
|
|
|
print("Failed to flush memcached", file=sys.stderr)
|
|
|
|
sys.exit(1)
|