acdc509630
Co-authored-by: hailey <me@haileyok.com> Co-authored-by: Stanislas Signoud <signez@stanisoft.net> Co-authored-by: will berry <wsb@wills-MBP.attlocal.net> Co-authored-by: BlueSkiesAndGreenPastures <will@blueskyweb.xyz> Co-authored-by: Chenyu Huang <itschenyu@gmail.com>
30 lines
754 B
TypeScript
30 lines
754 B
TypeScript
import {Database, envToCfg, httpLogger, LinkService, readEnv} from './index.js'
|
|
async function main() {
|
|
const env = readEnv()
|
|
const cfg = envToCfg(env)
|
|
if (cfg.db.migrationUrl) {
|
|
const migrateDb = Database.postgres({
|
|
url: cfg.db.migrationUrl,
|
|
schema: cfg.db.schema,
|
|
})
|
|
await migrateDb.migrateToLatestOrThrow()
|
|
await migrateDb.close()
|
|
}
|
|
|
|
const link = await LinkService.create(cfg)
|
|
|
|
if (link.ctx.cfg.service.safelinkEnabled) {
|
|
link.ctx.safelinkClient.runFetchEvents()
|
|
}
|
|
|
|
await link.start()
|
|
httpLogger.info('link service is running')
|
|
process.on('SIGTERM', async () => {
|
|
httpLogger.info('link service is stopping')
|
|
await link.destroy()
|
|
httpLogger.info('link service is stopped')
|
|
})
|
|
}
|
|
|
|
main()
|