Pinafore-Web-Client-Frontend/bin/wait-for-mastodon-to-start.js

27 lines
686 B
JavaScript
Raw Normal View History

2018-02-18 21:03:37 +01:00
const fetch = require('node-fetch')
2018-02-19 00:30:42 +01:00
async function waitForMastodonToStart () {
2018-02-18 21:03:37 +01:00
while (true) {
try {
let json = await ((await fetch('http://127.0.0.1:3000/api/v1/instance')).json())
2018-02-19 02:28:08 +01:00
let html = await ((await fetch('http://127.0.0.1:3035/packs/common.js')).text())
if (json.uri && html) {
2018-02-18 21:03:37 +01:00
break
}
} catch (err) {
console.log('Waiting for Mastodon to start up...')
await new Promise(resolve => setTimeout(resolve, 1000))
}
}
console.log('Mastodon started up')
}
module.exports = waitForMastodonToStart
if (require.main === module) {
waitForMastodonToStart().catch(err => {
console.error(err)
process.exit(1)
})
2018-02-19 00:30:42 +01:00
}