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);
|
||||
}
|
||||
|
||||
public void destroy() {
|
||||
public void close() {
|
||||
db.close();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@ public class MovieDatabase extends TupleBinding<Chunk> {
|
|||
this.db = environment.openDatabase(null, dbname, databaseConfig);
|
||||
}
|
||||
|
||||
public void destroy() {
|
||||
public void close() {
|
||||
db.close();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ public class ThumbnailDatabase extends TupleBinding<CachedImage> {
|
|||
this.db = environment.openDatabase(null, dbname, databaseConfig);
|
||||
}
|
||||
|
||||
public void destroy() {
|
||||
public void close() {
|
||||
db.close();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -179,9 +179,10 @@ public class AlbumServlet
|
|||
}
|
||||
|
||||
|
||||
public void destroy() {
|
||||
dirDb.destroy();
|
||||
thumbDb.destroy();
|
||||
public void close() {
|
||||
dirDb.close();
|
||||
thumbDb.close();
|
||||
movieDb.close();
|
||||
environment.close();
|
||||
}
|
||||
|
||||
|
|
@ -558,6 +559,7 @@ public class AlbumServlet
|
|||
@Override
|
||||
public void destroy() {
|
||||
log.info("Shutting down Album");
|
||||
roots.values().forEach(r -> r.close());
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -24,6 +24,15 @@ public class Runner {
|
|||
server.start();
|
||||
|
||||
System.out.println("Visit http://localhost:8080/photo/album/");
|
||||
|
||||
Runtime.getRuntime().addShutdownHook(new Thread(() -> {
|
||||
try {
|
||||
server.stop();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}));
|
||||
|
||||
server.join();
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue