-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use channels to handle turdserve errors
- Loading branch information
Showing
8 changed files
with
64 additions
and
40 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
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
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
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 |
---|---|---|
@@ -1,24 +1,25 @@ | ||
#!/bin/bash | ||
# Script that launches two games at once (for multiplayer testing) | ||
|
||
cleanup() { | ||
echo "Stopping processes..." | ||
kill $pid1 $pid2 2>/dev/null | ||
wait $pid1 2>/dev/null | ||
wait $pid2 2>/dev/null | ||
exit | ||
} | ||
|
||
# Trap for Ctrl+C to clean up processes | ||
trap cleanup INT | ||
|
||
# Start the processes in the background | ||
process1_command="go run cmd/main.go --screen multiplayerHost" | ||
$process1_command & | ||
process1_command="go run cmd/main.go --screen multiplayerJoin" | ||
$process1_command 2>&1 & | ||
pid1=$! | ||
|
||
process2_command="go run cmd/main.go --screen multiplayerJoin" | ||
$process2_command & | ||
process2_command="go run cmd/main.go --screen multiplayerHost" | ||
$process2_command 2>&1 & | ||
pid2=$! | ||
|
||
# Wait for either process to finish | ||
wait -n $pid1 $pid2 | ||
|
||
# If one process ends, clean up both | ||
echo "Stopping processes..." | ||
kill $pid1 $pid2 2>/dev/null | ||
wait $pid1 2>/dev/null | ||
wait $pid2 2>/dev/null | ||
exit |
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
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
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
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