plinth-infra/pds/index.mjs

30 lines
756 B
JavaScript
Raw Permalink Normal View History

2024-11-19 05:25:01 +00:00
import "dotenv/config";
import { envStr } from "@atproto/common";
import { PDS, envToCfg, envToSecrets, readEnv } from "@atproto/pds";
import pkg from "@atproto/pds/package.json" with { type: "json" };
import process from "node:process";
const main = async () => {
const env = readEnv();
env.version ||= pkg.version;
const cfg = envToCfg(env);
const secrets = envToSecrets(env);
const pds = await PDS.create(cfg, secrets);
// allow listening on non-0.0.0.0 addresses
const host = envStr("BIND_HOST") ?? "127.0.0.1";
const oListen = pds.app.listen;
pds.app.listen = (port, ...args) => {
return oListen(port, host, ...args);
}
await pds.start();
process.on("SIGTERM", async () => {
await pds.destroy();
});
};
main();