mirror of
https://github.com/ArchiveBox/ArchiveBox.git
synced 2025-05-13 22:54:27 -04:00
fuck it go back to nested lib and tmp dirs with supervisord sock workaround
This commit is contained in:
parent
df68f416fb
commit
4b34b729ab
6 changed files with 52 additions and 21 deletions
|
@ -1,14 +1,33 @@
|
|||
import tempfile
|
||||
from pathlib import Path
|
||||
|
||||
from archivebox.config import CONSTANTS
|
||||
from archivebox.config.paths import get_collection_id
|
||||
|
||||
DATA_DIR = CONSTANTS.DATA_DIR
|
||||
LOGS_DIR = CONSTANTS.LOGS_DIR
|
||||
TMP_DIR = CONSTANTS.TMP_DIR
|
||||
|
||||
Path.mkdir(TMP_DIR, exist_ok=True)
|
||||
SUPERVISORD_CONFIG_FILE = TMP_DIR / "supervisord.conf"
|
||||
PID_FILE = TMP_DIR / "supervisord.pid"
|
||||
SOCK_FILE = TMP_DIR / "supervisord.sock"
|
||||
LOG_FILE = TMP_DIR / "supervisord.log"
|
||||
WORKERS_DIR = TMP_DIR / "workers"
|
||||
|
||||
|
||||
def get_sock_file():
|
||||
TMP_DIR.mkdir(parents=True, exist_ok=True)
|
||||
|
||||
if len(str(SOCK_FILE)) > 100:
|
||||
# socket absolute paths cannot be longer than 108 characters on some systems
|
||||
# symlink it to a shorter path and use that instead
|
||||
|
||||
# use tmpfile to atomically overwrite any existing symlink
|
||||
symlink = Path(tempfile.gettempdir()) / f"archivebox_supervisord_{get_collection_id()}.sock.tmp"
|
||||
symlink.unlink(missing_ok=True)
|
||||
symlink.symlink_to(SOCK_FILE)
|
||||
symlink.rename(str(symlink).replace('.sock.tmp', '.sock'))
|
||||
assert len(str(symlink)) <= 100, f'Failed to create supervisord SOCK_FILE, system tmp dir location is too long {symlink} (unix only allows 108 characters for socket paths)'
|
||||
return symlink
|
||||
|
||||
return SOCK_FILE
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue