-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create a script that spins up multiple nodes listening for requests o…
…n different ports (#8) * Make spindown script * Iterate through the ports and create a port address list * Finish the spin down script * Final cleanup with SIGTERM * Finish account for bound ports * Finish implementing spin down script spinning down based on port_list.txt --------- Co-authored-by: Nghi Nguyen <quangnghiams@gmail.com>
- Loading branch information
Showing
3 changed files
with
50 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -89,3 +89,5 @@ ENV/ | |
# Rope project settings | ||
.ropeproject | ||
|
||
# Spin up script | ||
devops/deploy/port_list.txt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#!/bin/bash | ||
|
||
# Now fully implemented spinning down through the port_list.txt | ||
IP=127.0.0.1 | ||
declare -a PORTS=() | ||
while IFS= read -r line | ||
do | ||
PORTS+=("$line") | ||
done < "port_list.txt" | ||
|
||
# Iterate through the list, killing each controlling process while looping | ||
for port in ${PORTS[*]} | ||
do | ||
echo "Killing processes at $IP:$port" | ||
temp=$IP:$port | ||
kill -15 $(netstat -anp | grep $temp | awk '{print $6}' | awk -F/ '{print $1}') | ||
done | ||
|
||
echo -n > "port_list.txt" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#!/bin/bash | ||
|
||
PSTART=${1:-50000} | ||
PEND=${2:-50050} | ||
# Just a basic script to spin up listening servers on different ports in dynamic port range | ||
IP=127.0.0.1 | ||
COUNT=0 | ||
((NUM_PORTS=${PEND}-${PSTART})) | ||
|
||
echo "Total number of ports: $NUM_PORTS" | ||
export PYTHONPATH=../../src/main/py | ||
|
||
port=$PSTART | ||
|
||
while [ ${COUNT} -lt ${NUM_PORTS} ] | ||
do | ||
#Check for Open ports, if open then OK, else continue | ||
if ! netstat -apn | grep -q "$IP:$port" | ||
then | ||
echo "Starting on port $port" | ||
python3 -m sample_module.udp_server ${port} & | ||
echo "$port" >> port_list.txt | ||
((port++)) | ||
((COUNT++)) | ||
else | ||
echo "Port $port already bound" | ||
((port++)) | ||
fi | ||
done |