31 lines
771 B
JavaScript
31 lines
771 B
JavaScript
"use strict"
|
|
|
|
require("dotenv").config();
|
|
|
|
const { envStr } = require("@atproto/common");
|
|
const { PDS, envToCfg, envToSecrets, readEnv } = require("@atproto/pds");
|
|
const pkg = require("@atproto/pds/package.json");
|
|
|
|
const process = require("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();
|