Skip to content
Snippets Groups Projects
Commit f944f6d7 authored by Dixon Tirtayadi's avatar Dixon Tirtayadi
Browse files

Added main.py to run multiple paxoses

parent 157d44d0
No related branches found
No related tags found
No related merge requests found
from audioop import add
import subprocess
import sys
import signal
import time
# Can spawn multiple paxos server
if __name__ == "__main__":
num_server = 2
# If they pass in num_server as argument
if len(sys.argv) == 2:
num_server = int(sys.argv[1])
HOST, PORT = "localhost", 9000
PORTSTART = 9000
PORTEND = PORTSTART + num_server - 1
processes = []
try:
for i in range(num_server):
proc = subprocess.Popen(["python3", "paxos.py", HOST, str(PORT + i), str(PORTSTART), str(PORTEND)])
processes.append(proc)
# Needed to sleep forever here until ctrl-c so we go into "finally" and kill processes
while True:
time.sleep(10)
finally:
for proc in processes:
# proc.send_signal(signal.SIGINT)
proc.kill()
\ No newline at end of file
......@@ -430,10 +430,13 @@ def send_msg(obj, dest_addr: Address):
if __name__ == "__main__":
HOST, PORT = sys.argv[1], int(sys.argv[2])
# addresses = ((HOST, PORT),)
addresses = ((HOST, 9000), (HOST, 9001))
# Create the server, binding to localhost on port 9999
PORTSTART, PORTEND = int(sys.argv[3]), int(sys.argv[4])
addresses = ()
for i in range(PORTSTART, PORTEND + 1):
addresses += ((HOST, i),)
# Create the server, binding to localhost on port 9999
server = Paxos((HOST, PORT), addresses)
# Activate the server; this will keep running until you
# interrupt the program with Ctrl-C
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment