3 Star 2 Fork 1

Gitee 极速下载 / serverless-dns

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
此仓库是为了提升国内下载速度的镜像仓库,每日同步一次。 原始仓库: https://github.com/serverless-dns/serverless-dns
克隆/下载
config.ts 2.11 KB
一键复制 编辑 原始数据 按行查看 历史
import * as system from "../../system.js";
import * as blocklists from "./blocklists.ts";
import * as dbip from "./dbip.ts";
import { services, stopAfter } from "../svc.js";
import Log, { LogLevels } from "../log.js";
import EnvManager from "../env.js";
import { signal } from "https://deno.land/std@0.171.0/signal/mod.ts";
// In global scope.
declare global {
// TypeScript must know type of every var / property. Extend Window
// (globalThis) with declaration merging (archive.is/YUWh2) to define types
// Ref: www.typescriptlang.org/docs/handbook/declaration-merging.html
interface Window {
envManager?: EnvManager;
log?: Log;
env?: any;
}
}
((main) => {
system.when("prepare").then(prep);
system.when("steady").then(up);
})();
async function sigctrl() {
const sigs = signal("SIGINT");
for await (const _ of sigs) {
stopAfter();
}
}
async function prep() {
// if this file execs... assume we're on deno.
if (!Deno) throw new Error("failed loading deno-specific config");
const isProd = Deno.env.get("DENO_ENV") === "production";
const onDenoDeploy = Deno.env.get("CLOUD_PLATFORM") === "deno-deploy";
const profiling = Deno.env.get("PROFILE_DNS_RESOLVES") === "true";
window.envManager = new EnvManager();
window.log = new Log({
level: window.envManager.get("LOG_LEVEL") as LogLevels,
levelize: isProd || profiling, // levelize if prod or profiling
withTimestamps: !onDenoDeploy, // do not log ts on deno-deploy
});
// signal ready
system.pub("ready");
}
async function up() {
if (!services.ready) {
console.error("services not yet ready and there is a sig-up!?");
return;
}
const bw = services.blocklistWrapper;
if (bw != null && !bw.disabled()) {
await blocklists.setup(bw);
} else {
console.warn("Config", "blocklists unavailable / disabled");
}
const lp = services.logPusher;
if (lp != null) {
try {
await dbip.setup(lp);
} catch (ex) {
console.error("Config", "dbip setup failed", ex);
}
} else {
console.warn("Config", "logpusher unavailable");
}
sigctrl();
// signal all system are-a go
system.pub("go");
}
JavaScript
1
https://gitee.com/mirrors/serverless-dns.git
git@gitee.com:mirrors/serverless-dns.git
mirrors
serverless-dns
serverless-dns
main

搜索帮助