Skip to content

Commit a905bf9

Browse files
committed
Adding a path for persistent data
To support persistent data with the server, this change adds a command line argument that specifies where cross run data can be stored.
1 parent e1edf2e commit a905bf9

File tree

2 files changed

+13
-6
lines changed

2 files changed

+13
-6
lines changed

run_server.sh

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,11 @@
1717
TEAM_ID="$1"
1818
TEAM_SECRET="$2"
1919
PORT="$3"
20-
RELAY_ADDRESS="$4"
20+
PERSISTENT="$4"
21+
RELAY_ADDRESS="$5"
2122

22-
if [[ "TEAM_ID" == "" || "$TEAM_SECRET" == "" || "$PORT" == "" ]] ; then
23-
echo 'usage: <TEAM ID> <TEAM SECRET> <PORT> [RELAY ADDRESS]'
23+
if [[ "TEAM_ID" == "" || "$TEAM_SECRET" == "" || "$PORT" == "" || "$PERSISTENT" == "" ]] ; then
24+
echo 'usage: <TEAM ID> <TEAM SECRET> <PORT> <PERSISENT> [RELAY ADDRESS]'
2425
exit 1
2526
fi
2627

@@ -29,11 +30,13 @@ if [ "$RELAY_ADDRESS" == "" ] ; then
2930
java codeu.chat.ServerMain \
3031
"$TEAM_ID" \
3132
"$TEAM_SECRET" \
32-
"$PORT"
33+
"$PORT" \
34+
"$PERSISTENT"
3335
else
3436
java codeu.chat.ServerMain \
3537
"$TEAM_ID" \
3638
"$TEAM_SECRET" \
3739
"$PORT" \
40+
"$PERSISTENT" \
3841
"$RELAY_ADDRESS"
3942
fi

src/codeu/chat/ServerMain.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,12 @@ public static void main(String[] args) {
5151

5252
final int myPort = Integer.parseInt(args[2]);
5353

54-
final RemoteAddress relayAddress = args.length > 3 ?
55-
RemoteAddress.parse(args[3]) :
54+
// This is the directory where it is safe to store data accross runs
55+
// of the server.
56+
final String persistentPath = args[3];
57+
58+
final RemoteAddress relayAddress = args.length > 4 ?
59+
RemoteAddress.parse(args[4]) :
5660
null;
5761

5862
try (

0 commit comments

Comments
 (0)