The pid file contains the process id of the running server.
In case the server crashes without removing the pid file, you can check if that process is actually running by using the *psutil* package for example, in a programmatic fashion.
Alternatively, you can create an application which starts listening to an address only if that address is not responding to a ping.
Something along these lines:
class Supervisor(pulsar.Application):
def monitor_task(self, monitor):
start = False
try:
yield do_the_ping_here(...)
except socket.error:
# There is no server
start = True
if start:
yield pulsar.send('arbiter', 'run', start_server)
def start_server(actor):
SocketServer(...).start()
There are several other ways of doing this, ultimately the best solution will depends on the actual use case.