-
Notifications
You must be signed in to change notification settings - Fork 2
/
index.js
24 lines (19 loc) · 840 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import { setupApp } from './lib/api.js'
import DistributedStorage from './lib/distributed-storage.js'
async function main () {
const host = process.env.WHALESONG_HOST || 'localhost'
const port = process.env.WHALESONG_PORT || '5005'
const hostport = `http://${host}:${port}`
const externalUrl = process.env.WHALESONG_EXTERNAL_URL || hostport
console.log('Initializing storage provider. Please wait.')
const storage = new DistributedStorage()
await storage.init()
const app = await setupApp(storage, host, port, externalUrl)
app.listen(port, host, () => {
console.log(`Whalesong listening at ${externalUrl}`)
})
}
process.on('unhandledRejection', error => {
console.error('==> Got unhandled rejection:', error.message)
})
main().catch(e => console.error(`top-level exception: ${e} json: ${JSON.stringify(e)}`))