Skip to content

Commit 74a3149

Browse files
committed
Add back optional host, improve error handling
1 parent dcc834a commit 74a3149

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

components/clp-py-utils/clp_py_utils/start-spider-worker.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ def parse_args() -> argparse.Namespace:
2626
"--concurrency", type=int, default=1, help="Number of concurrent spider workers."
2727
)
2828
parser.add_argument("--storage-url", type=str, required=True, help="Spider storage URL.")
29+
parser.add_argument("--host", type=str, required=False, default=None, help="The worker host.")
2930
return parser.parse_args()
3031

3132

@@ -38,7 +39,13 @@ def main() -> None:
3839
logger.error("Concurrency must be at least 1.")
3940
exit(1)
4041
storage_url = args.storage_url
41-
host = socket.gethostbyname(socket.gethostname())
42+
host = args.host
43+
if host is None:
44+
try:
45+
host = socket.gethostbyname(socket.gethostname())
46+
except (socket.gaierror, socket.herror) as e:
47+
logger.error(f"Failed to resolve hostname: {e}")
48+
exit(1)
4249

4350
clp_home = os.getenv("CLP_HOME", "/opt/clp")
4451
spider_worker_path = pathlib.Path(clp_home) / "bin" / "spider_worker"

0 commit comments

Comments
 (0)