fix: recursive require in test env
This commit is contained in:
@@ -24,6 +24,7 @@ import onerror from "./onerror";
|
|||||||
import ShutdownHelper, { ShutdownOrder } from "./utils/ShutdownHelper";
|
import ShutdownHelper, { ShutdownOrder } from "./utils/ShutdownHelper";
|
||||||
import { sequelize } from "./database/sequelize";
|
import { sequelize } from "./database/sequelize";
|
||||||
import RedisAdapter from "./redis";
|
import RedisAdapter from "./redis";
|
||||||
|
import Metrics from "./logging/Metrics";
|
||||||
|
|
||||||
// The default is to run all services to make development and OSS installations
|
// The default is to run all services to make development and OSS installations
|
||||||
// easier to deal with. Separate services are only needed at scale.
|
// easier to deal with. Separate services are only needed at scale.
|
||||||
@@ -154,6 +155,8 @@ async function start(id: number, disconnect: () => void) {
|
|||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|
||||||
|
ShutdownHelper.add("metrics", ShutdownOrder.last, () => Metrics.flush());
|
||||||
|
|
||||||
// Handle shutdown signals
|
// Handle shutdown signals
|
||||||
process.once("SIGTERM", () => ShutdownHelper.execute());
|
process.once("SIGTERM", () => ShutdownHelper.execute());
|
||||||
process.once("SIGINT", () => ShutdownHelper.execute());
|
process.once("SIGINT", () => ShutdownHelper.execute());
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
import ddMetrics from "datadog-metrics";
|
import ddMetrics from "datadog-metrics";
|
||||||
import env from "@server/env";
|
import env from "@server/env";
|
||||||
import ShutdownHelper, { ShutdownOrder } from "@server/utils/ShutdownHelper";
|
|
||||||
|
|
||||||
class Metrics {
|
class Metrics {
|
||||||
enabled = !!env.DD_API_KEY;
|
enabled = !!env.DD_API_KEY;
|
||||||
@@ -15,8 +14,6 @@ class Metrics {
|
|||||||
prefix: "outline.",
|
prefix: "outline.",
|
||||||
defaultTags: [`env:${process.env.DD_ENV ?? env.ENVIRONMENT}`],
|
defaultTags: [`env:${process.env.DD_ENV ?? env.ENVIRONMENT}`],
|
||||||
});
|
});
|
||||||
|
|
||||||
ShutdownHelper.add("metrics", ShutdownOrder.last, () => this.flush());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
gauge(key: string, value: number, tags?: string[]): void {
|
gauge(key: string, value: number, tags?: string[]): void {
|
||||||
|
|||||||
@@ -57,7 +57,7 @@ if (env.CDN_URL) {
|
|||||||
defaultSrc.push(env.CDN_URL);
|
defaultSrc.push(env.CDN_URL);
|
||||||
}
|
}
|
||||||
|
|
||||||
export default function init(app: Koa = new Koa(), server: Server): Koa {
|
export default function init(app: Koa = new Koa(), server?: Server): Koa {
|
||||||
initI18n();
|
initI18n();
|
||||||
|
|
||||||
if (isProduction) {
|
if (isProduction) {
|
||||||
@@ -85,7 +85,7 @@ export default function init(app: Koa = new Koa(), server: Server): Koa {
|
|||||||
app.use(mount("/api", api));
|
app.use(mount("/api", api));
|
||||||
|
|
||||||
// Monitor server connections
|
// Monitor server connections
|
||||||
if (env.ENVIRONMENT !== "test") {
|
if (server) {
|
||||||
setInterval(async () => {
|
setInterval(async () => {
|
||||||
server.getConnections((err, count) => {
|
server.getConnections((err, count) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
|
|||||||
Reference in New Issue
Block a user