diff --git a/packages/api/src/app/stream-info/parse-cli.ts b/packages/api/src/app/stream-info/parse-cli.ts index 22f2c5f1d..a45906c52 100644 --- a/packages/api/src/app/stream-info/parse-cli.ts +++ b/packages/api/src/app/stream-info/parse-cli.ts @@ -37,6 +37,17 @@ export function parseCli() { type: "string", demandOption: true, }, + "postgres-create-tables": { + describe: + "create tables and indexes on the database if they don't exist", + type: "boolean", + default: false, + }, + "postgres-conn-pool-size": { + describe: "size of the postgres connection pool", + type: "number", + default: 5, + }, }) .help() .parse(); diff --git a/packages/api/src/app/stream-info/stream-info-app.ts b/packages/api/src/app/stream-info/stream-info-app.ts index 5f6240ecb..2f9c02a9d 100644 --- a/packages/api/src/app/stream-info/stream-info-app.ts +++ b/packages/api/src/app/stream-info/stream-info-app.ts @@ -1,19 +1,19 @@ import express, { Router } from "express"; import "express-async-errors"; // it monkeypatches, i guess import morgan from "morgan"; -import { db } from "../../store"; -import { healthCheck } from "../../middleware"; -import logger from "../../logger"; -import { Stream } from "../../schema/types"; import fetch from "node-fetch"; import { hostname } from "os"; +import logger from "../../logger"; +import { healthCheck } from "../../middleware"; +import { Stream } from "../../schema/types"; +import { db } from "../../store"; +import { DBStream } from "../../store/stream-table"; import { - StatusResponse, MasterPlaylist, MasterPlaylistDictionary, + StatusResponse, } from "./livepeer-types"; -import { DBStream } from "../../store/stream-table"; import { CliArgs } from "./parse-cli"; const pollInterval = 2 * 1000; // 2s @@ -377,9 +377,22 @@ class statusPoller { } export default async function makeApp(params: CliArgs) { - const { port, postgresUrl, ownRegion, listen = true, broadcaster } = params; + const { + port, + postgresUrl, + ownRegion, + listen = true, + broadcaster, + postgresCreateTables, + postgresConnPoolSize, + } = params; // Storage init - await db.start({ postgresUrl, appName: "stream-info" }); + await db.start({ + postgresUrl, + appName: "stream-info", + createTablesOnDb: postgresCreateTables, + poolMaxSize: postgresConnPoolSize, + }); const { router } = await makeRouter(params); const app = express();