More orderly shutdown
This commit is contained in:
parent
55591da0a6
commit
9851784fde
5 changed files with 17 additions and 6 deletions
|
|
@ -42,7 +42,7 @@ public class DirectoryDatabase extends TupleBinding<DirectoryProps> {
|
||||||
this.db = environment.openDatabase(null, dbname, databaseConfig);
|
this.db = environment.openDatabase(null, dbname, databaseConfig);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void destroy() {
|
public void close() {
|
||||||
db.close();
|
db.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -39,7 +39,7 @@ public class MovieDatabase extends TupleBinding<Chunk> {
|
||||||
this.db = environment.openDatabase(null, dbname, databaseConfig);
|
this.db = environment.openDatabase(null, dbname, databaseConfig);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void destroy() {
|
public void close() {
|
||||||
db.close();
|
db.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -41,7 +41,7 @@ public class ThumbnailDatabase extends TupleBinding<CachedImage> {
|
||||||
this.db = environment.openDatabase(null, dbname, databaseConfig);
|
this.db = environment.openDatabase(null, dbname, databaseConfig);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void destroy() {
|
public void close() {
|
||||||
db.close();
|
db.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -179,9 +179,10 @@ public class AlbumServlet
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void destroy() {
|
public void close() {
|
||||||
dirDb.destroy();
|
dirDb.close();
|
||||||
thumbDb.destroy();
|
thumbDb.close();
|
||||||
|
movieDb.close();
|
||||||
environment.close();
|
environment.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -558,6 +559,7 @@ public class AlbumServlet
|
||||||
@Override
|
@Override
|
||||||
public void destroy() {
|
public void destroy() {
|
||||||
log.info("Shutting down Album");
|
log.info("Shutting down Album");
|
||||||
|
roots.values().forEach(r -> r.close());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -24,6 +24,15 @@ public class Runner {
|
||||||
server.start();
|
server.start();
|
||||||
|
|
||||||
System.out.println("Visit http://localhost:8080/photo/album/");
|
System.out.println("Visit http://localhost:8080/photo/album/");
|
||||||
|
|
||||||
|
Runtime.getRuntime().addShutdownHook(new Thread(() -> {
|
||||||
|
try {
|
||||||
|
server.stop();
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}));
|
||||||
|
|
||||||
server.join();
|
server.join();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue