Adding shutdown mode to make it easier to restart server.
This commit is contained in:
@@ -30,6 +30,8 @@ public class HallServer extends AbstractServer {
|
|||||||
|
|
||||||
private String _motd;
|
private String _motd;
|
||||||
|
|
||||||
|
private boolean _shutdown;
|
||||||
|
|
||||||
private Map<String, LotroFormat> _supportedFormats = new LinkedHashMap<String, LotroFormat>();
|
private Map<String, LotroFormat> _supportedFormats = new LinkedHashMap<String, LotroFormat>();
|
||||||
|
|
||||||
|
|
||||||
@@ -65,6 +67,12 @@ public class HallServer extends AbstractServer {
|
|||||||
addFormat("expanded", new ExpandedFormat(library));
|
addFormat("expanded", new ExpandedFormat(library));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setShutdown(boolean shutdown) {
|
||||||
|
_shutdown = shutdown;
|
||||||
|
if (shutdown)
|
||||||
|
cancelWaitingTables();
|
||||||
|
}
|
||||||
|
|
||||||
public String getMOTD() {
|
public String getMOTD() {
|
||||||
return _motd;
|
return _motd;
|
||||||
}
|
}
|
||||||
@@ -89,10 +97,22 @@ public class HallServer extends AbstractServer {
|
|||||||
return _leagueService.getActiveLeagues();
|
return _leagueService.getActiveLeagues();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void cancelWaitingTables() {
|
||||||
|
_hallDataAccessLock.writeLock().lock();
|
||||||
|
try {
|
||||||
|
_awaitingTables.clear();
|
||||||
|
} finally {
|
||||||
|
_hallDataAccessLock.writeLock().unlock();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return If table created, otherwise <code>false</code> (if the user already is sitting at a table or playing).
|
* @return If table created, otherwise <code>false</code> (if the user already is sitting at a table or playing).
|
||||||
*/
|
*/
|
||||||
public void createNewTable(String type, Player player, String deckName) throws HallException {
|
public void createNewTable(String type, Player player, String deckName) throws HallException {
|
||||||
|
if (_shutdown)
|
||||||
|
throw new HallException("Server is in shutdown mode. Server will be restarted after all running games are finished.");
|
||||||
|
|
||||||
_hallDataAccessLock.writeLock().lock();
|
_hallDataAccessLock.writeLock().lock();
|
||||||
try {
|
try {
|
||||||
League league = null;
|
League league = null;
|
||||||
|
|||||||
@@ -50,6 +50,18 @@ public class AdminResource extends AbstractResource {
|
|||||||
return "OK";
|
return "OK";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Path("/shutdown")
|
||||||
|
@GET
|
||||||
|
public String shutdown(
|
||||||
|
@QueryParam("shutdown") boolean shutdown,
|
||||||
|
@Context HttpServletRequest request) throws Exception {
|
||||||
|
validateAdmin(request);
|
||||||
|
|
||||||
|
_hallServer.setShutdown(shutdown);
|
||||||
|
|
||||||
|
return "OK";
|
||||||
|
}
|
||||||
|
|
||||||
@Path("/setMotd")
|
@Path("/setMotd")
|
||||||
@POST
|
@POST
|
||||||
public String setMotd(
|
public String setMotd(
|
||||||
|
|||||||
Reference in New Issue
Block a user