| 273 | } |
| 274 | |
| 275 | private void addShutdownHook() { |
| 276 | Runtime.getRuntime().addShutdownHook(new Thread(() -> { |
| 277 | try { |
| 278 | System.err.println("SIGTERM received"); |
| 279 | System.out.println("SIGTERM received"); |
| 280 | // It's fine if the magic number doesn't get its way to logs. |
| 281 | // We log it merely to make sure that LOAD instructions generated by |
| 282 | // AsyncFilterAtom#preTouchColumns() aren't optimized away by JVM's JIT compiler. |
| 283 | bootstrap.getLog().debug().$("Pre-touch magic number: ").$(AsyncFilterAtom.PRE_TOUCH_BLACK_HOLE.sum()).$(); |
| 284 | close(); |
| 285 | LogFactory.closeInstance(); |
| 286 | } catch (Error ignore) { |
| 287 | // ignore |
| 288 | } finally { |
| 289 | System.err.println("QuestDB is shutdown."); |
| 290 | System.out.println("QuestDB is shutdown."); |
| 291 | } |
| 292 | })); |
| 293 | } |
| 294 | |
| 295 | private synchronized void initialize(Log log) { |
| 296 | initialized = true; |