Skip to content

Commit

Permalink
feat: detect up status
Browse files Browse the repository at this point in the history
  • Loading branch information
just-paja committed Jun 8, 2023
1 parent 0a0f1e4 commit 76b5d9b
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions packages/djorm/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ const getSettings = (configPath, defaultValue = null) => {
return result === undefined ? defaultValue : result
}

let up = false

const init = async () => {
const settings = getSettings()
if (settings.apps) {
Expand All @@ -37,6 +39,7 @@ const init = async () => {
if (settings.databases) {
await require('./init/databases').init(settings.databases)
}
up = true
}

const shutdown = async () => {
Expand All @@ -45,11 +48,15 @@ const shutdown = async () => {
require('./init/logger').shutdown()
require('./init/storages').shutdown()
require('./init/databases').shutdown()
up = false
}

const isUp = () => up

module.exports = {
configure,
getSettings,
isUp,
init,
shutdown
}

0 comments on commit 76b5d9b

Please sign in to comment.