Skip to content
This repository was archived by the owner on Sep 19, 2021. It is now read-only.

Commit 60ba7ad

Browse files
committed
Relay re-load teams file
Before the relay would only read the teams file at the start-up. This meant that the relay would have to be restarted whenever a new team was added. This change makes the relay reload the teams file every minute so that if a new team is added, they will have access within a minute. This will prevent the relay having to be taken down and losing all its data each time a new team comes on line.
1 parent 810f2d9 commit 60ba7ad

1 file changed

Lines changed: 15 additions & 8 deletions

File tree

src/codeu/chat/RelayMain.java

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -54,29 +54,36 @@ public static void main(String[] args) {
5454

5555
LOG.info("Relay object created.");
5656

57-
LOG.info("Loading team data...");
58-
59-
loadTeamInfo(relay, args[1]);
60-
61-
LOG.info("Done loading team data.");
62-
6357
LOG.info("Starting relay...");
6458

65-
startRelay(relay, source);
59+
startRelay(relay, source, args[1]);
6660

6761
} catch (IOException ex) {
6862
LOG.error(ex, "Failed to establish server accept port");
6963
}
7064
}
7165

72-
private static void startRelay(Server relay, ConnectionSource source) {
66+
private static void startRelay(Server relay, ConnectionSource source, String teamFile) {
7367

7468
final ServerFrontEnd frontEnd = new ServerFrontEnd(relay);
7569
LOG.info("Relay front end object created.");
7670

7771
final Timeline timeline = new Timeline();
7872
LOG.info("Relay timeline created.");
7973

74+
timeline.scheduleNow(new Runnable() {
75+
@Override
76+
public void run() {
77+
LOG.info("Loading team data...");
78+
loadTeamInfo(relay, teamFile);
79+
LOG.info("Done loading team data.");
80+
81+
// Add this again in 1 minute so that new entries to the time line will
82+
// be added. This won't support updating entries.
83+
timeline.scheduleIn(60000, this);
84+
}
85+
});
86+
8087
LOG.info("Starting relay main loop...");
8188

8289
while (true) {

0 commit comments

Comments
 (0)