Shuts down the server.
()
| 189 | * Shuts down the server. |
| 190 | */ |
| 191 | private synchronized void close() { |
| 192 | if(!running) return; |
| 193 | |
| 194 | for(final ClientListener cl : authorizing) { |
| 195 | remove(cl); |
| 196 | cl.close(); |
| 197 | } |
| 198 | context.sessions.close(); |
| 199 | |
| 200 | try { |
| 201 | // close interactive input if server was stopped by another process |
| 202 | socket.close(); |
| 203 | } catch(final IOException ex) { |
| 204 | Util.errln(ex); |
| 205 | context.log.writeServer(LogType.ERROR, Util.message(ex)); |
| 206 | } |
| 207 | |
| 208 | final int port = context.soptions.get(StaticOptions.SERVERPORT); |
| 209 | final String stopX = Util.info(SRV_STOPPED_PORT_X, port); |
| 210 | if(!quiet) Util.println(stopX); |
| 211 | context.log.writeServer(LogType.OK, stopX); |
| 212 | |
| 213 | // close database context |
| 214 | context.close(); |
| 215 | |
| 216 | if(!stopFile.delete()) { |
| 217 | context.log.writeServer(LogType.ERROR, Util.info(FILE_NOT_DELETED_X, stopFile)); |
| 218 | } |
| 219 | running = false; |
| 220 | } |
| 221 | |
| 222 | @Override |
| 223 | protected void parseArgs() throws IOException { |