()
| 17 | sys.exit(0) |
| 18 | |
| 19 | def run_worker(): |
| 20 | global db_instance |
| 21 | |
| 22 | # Get configuration from env |
| 23 | db_path = os.getenv('FALKORDB_PATH') |
| 24 | socket_path = os.getenv('FALKORDB_SOCKET_PATH') |
| 25 | |
| 26 | if not db_path or not socket_path: |
| 27 | logger.error("Missing configuration. FALKORDB_PATH and FALKORDB_SOCKET_PATH must be set.") |
| 28 | sys.exit(1) |
| 29 | |
| 30 | # Ensure dir exists |
| 31 | Path(db_path).parent.mkdir(parents=True, exist_ok=True) |
| 32 | |
| 33 | logger.info(f"Starting FalkorDB Lite worker...") |
| 34 | logger.info(f"DB Path: {db_path}") |
| 35 | logger.info(f"Socket: {socket_path}") |
| 36 | |
| 37 | try: |
| 38 | import platform |
| 39 | |
| 40 | if platform.system() == "Windows": |
| 41 | raise RuntimeError( |
| 42 | "CodeGraphContext uses redislite/FalkorDB, which does not support Windows.\n" |
| 43 | "Please run the project using WSL or Docker." |
| 44 | ) |
| 45 | |
| 46 | from redislite.falkordb_client import FalkorDB |
| 47 | |
| 48 | # Determine module path for frozen bundles |
| 49 | server_config = {} |
| 50 | if getattr(sys, 'frozen', False): |
| 51 | mei_pass = getattr(sys, '_MEIPASS', os.path.dirname(sys.executable)) |
| 52 | exe_dir = os.path.dirname(sys.executable) |
| 53 | |
| 54 | # All known locations PyInstaller may extract falkordb.so to |
| 55 | potential_paths = [ |
| 56 | # Standard redislite layout |
| 57 | os.path.join(mei_pass, 'redislite', 'bin', 'falkordb.so'), |
| 58 | # falkordblite scripts layout |
| 59 | os.path.join(mei_pass, 'falkordblite.scripts', 'falkordb.so'), |
| 60 | # Root of the bundle (add_binary with '.' target) |
| 61 | os.path.join(mei_pass, 'falkordb.so'), |
| 62 | # Alongside the executable itself |
| 63 | os.path.join(exe_dir, 'falkordb.so'), |
| 64 | # redislite data dir variant |
| 65 | os.path.join(mei_pass, 'redislite', 'falkordb.so'), |
| 66 | # falkordblite.libs (shared-lib bundle) |
| 67 | os.path.join(mei_pass, 'falkordblite.libs', 'falkordb.so'), |
| 68 | ] |
| 69 | |
| 70 | module_path = None |
| 71 | for p in potential_paths: |
| 72 | if os.path.exists(p): |
| 73 | module_path = p |
| 74 | break |
| 75 | |
| 76 | if module_path: |
no test coverage detected