Skip to content

Commit

Permalink
Merge pull request #1471 from locustio/more-user-friendly-logging-whe…
Browse files Browse the repository at this point in the history
…n-locust-master-port-is-busy

Improve logging when locust master port is busy.
  • Loading branch information
cyberw authored Jul 7, 2020
2 parents a141a5a + 8968ee6 commit 1d14cad
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion locust/runners.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import logging
import random
import socket
import sys
import traceback
import warnings
from uuid import uuid4
Expand Down Expand Up @@ -399,7 +400,16 @@ def missing(self):
return self.get_by_state(STATE_MISSING)

self.clients = WorkerNodesDict()
self.server = rpc.Server(master_bind_host, master_bind_port)
try:
self.server = rpc.Server(master_bind_host, master_bind_port)
except RPCError as e:
if e.args[0] == "Socket bind failure: Address already in use":
port_string = master_bind_host + ":" + master_bind_port if master_bind_host != "*" else master_bind_port
logger.error(f"The Locust master port ({port_string}) was busy. Close any applications using that port - perhaps an old instance of Locust master is still running? ({e.args[0]})")
sys.exit(1)
else:
raise

self.greenlet.spawn(self.heartbeat_worker).link_exception(greenlet_exception_handler)
self.greenlet.spawn(self.client_listener).link_exception(greenlet_exception_handler)

Expand Down

0 comments on commit 1d14cad

Please sign in to comment.