diff options
Diffstat (limited to 'bskylink/src/bin.ts')
-rw-r--r-- | bskylink/src/bin.ts | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/bskylink/src/bin.ts b/bskylink/src/bin.ts new file mode 100644 index 000000000..17f068841 --- /dev/null +++ b/bskylink/src/bin.ts @@ -0,0 +1,24 @@ +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) + 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() |