Shutdown stop database handles and stop service the database.
()
| 345 | |
| 346 | // Shutdown stop database handles and stop service the database. |
| 347 | func (db *Database) Shutdown() (err error) { |
| 348 | if db.kayakRuntime != nil { |
| 349 | // shutdown, stop kayak |
| 350 | if err = db.kayakRuntime.Shutdown(); err != nil { |
| 351 | return |
| 352 | } |
| 353 | |
| 354 | // unregister |
| 355 | db.mux.unregister(db.dbID) |
| 356 | } |
| 357 | |
| 358 | if db.kayakWal != nil { |
| 359 | // shutdown, stop kayak |
| 360 | db.kayakWal.Close() |
| 361 | } |
| 362 | |
| 363 | if db.chain != nil { |
| 364 | // stop chain |
| 365 | if err = db.chain.Stop(); err != nil { |
| 366 | return |
| 367 | } |
| 368 | } |
| 369 | |
| 370 | if db.connSeqEvictCh != nil { |
| 371 | // stop connection sequence evictions |
| 372 | select { |
| 373 | case _, ok := <-db.connSeqEvictCh: |
| 374 | if ok { |
| 375 | close(db.connSeqEvictCh) |
| 376 | } |
| 377 | default: |
| 378 | close(db.connSeqEvictCh) |
| 379 | } |
| 380 | } |
| 381 | |
| 382 | return |
| 383 | } |
| 384 | |
| 385 | // Destroy stop database instance and destroy all data/meta. |
| 386 | func (db *Database) Destroy() (err error) { |