feat: try to capture logs
This commit is contained in:
@@ -69,7 +69,7 @@ class LightsparkSparkWallet(Wallet):
|
|||||||
repo, branch = "spark_sidecar", "main"
|
repo, branch = "spark_sidecar", "main"
|
||||||
|
|
||||||
node_modules_path = Path(self._sidecar_path, f"{repo}-{branch}")
|
node_modules_path = Path(self._sidecar_path, f"{repo}-{branch}")
|
||||||
if not Path(self._sidecar_path, "package.json").is_file():
|
if not Path(node_modules_path, "package.json").is_file():
|
||||||
logger.info("⏳ Downloading Spark sidecar.")
|
logger.info("⏳ Downloading Spark sidecar.")
|
||||||
await asyncio.to_thread(
|
await asyncio.to_thread(
|
||||||
download_url,
|
download_url,
|
||||||
@@ -84,6 +84,8 @@ class LightsparkSparkWallet(Wallet):
|
|||||||
)
|
)
|
||||||
logger.info("✅ Extracted Spark sidecar.")
|
logger.info("✅ Extracted Spark sidecar.")
|
||||||
# todo: remove zip
|
# todo: remove zip
|
||||||
|
else:
|
||||||
|
logger.info("Spark sidecar already downloaded.")
|
||||||
|
|
||||||
|
|
||||||
if not Path(self._sidecar_path, node_modules_path, "node_modules").is_dir():
|
if not Path(self._sidecar_path, node_modules_path, "node_modules").is_dir():
|
||||||
@@ -99,17 +101,31 @@ class LightsparkSparkWallet(Wallet):
|
|||||||
print(result.stderr)
|
print(result.stderr)
|
||||||
|
|
||||||
print("### Starting Spark sidecar node server")
|
print("### Starting Spark sidecar node server")
|
||||||
result = subprocess.run(
|
# result = subprocess.run(
|
||||||
|
# ["node", "server.mjs"],
|
||||||
|
# cwd=str(node_modules_path),
|
||||||
|
# capture_output=True,
|
||||||
|
# text=True,
|
||||||
|
# # check=True, # raises an exception if node fails
|
||||||
|
# )
|
||||||
|
|
||||||
|
# print("### Spark sidecar output:")
|
||||||
|
# print(result.stdout)
|
||||||
|
# print(result.stderr)
|
||||||
|
|
||||||
|
process = subprocess.Popen(
|
||||||
["node", "server.mjs"],
|
["node", "server.mjs"],
|
||||||
cwd=str(node_modules_path),
|
cwd=str(node_modules_path),
|
||||||
capture_output=True,
|
stdout=subprocess.PIPE,
|
||||||
text=True,
|
stderr=subprocess.STDOUT,
|
||||||
# check=True, # raises an exception if node fails
|
text=True
|
||||||
)
|
)
|
||||||
|
|
||||||
print("### Spark sidecar output:")
|
if process.stdout:
|
||||||
print(result.stdout)
|
for line in process.stdout:
|
||||||
print(result.stderr)
|
logger.info(f"Spark: {line}", end="")
|
||||||
|
else:
|
||||||
|
logger.warning(" No output captured for Spark sidecar.")
|
||||||
|
|
||||||
async def cleanup(self):
|
async def cleanup(self):
|
||||||
try:
|
try:
|
||||||
|
|||||||
Reference in New Issue
Block a user