-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
api: bundle stream-info-service (#1184)
* api: bundle stream-info-service * api/stream-info: Move parse-cli to a separate file * api: Add stream-info-service arg to parseCli directly - The host field in the stream-info-service was never used - The broadcaster field was missing in the API, added with the disclaimer This introduces a small tech debt with the API CLI args containing something not relevant to it (broadcaster), but I think it's ok for now especially if we get rid of stream-info-service for good soon. * stream-info-service: identify yourself --------- Co-authored-by: Victor Elias <[email protected]>
- Loading branch information
Showing
6 changed files
with
79 additions
and
66 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import "source-map-support/register"; | ||
import yargs from "yargs"; | ||
import { CamelKeys } from "../../types/common"; | ||
|
||
export type CliArgs = ReturnType<typeof parseCli>; | ||
|
||
export function parseCli() { | ||
const parsed = yargs | ||
.usage( | ||
` | ||
Livepeer Stream Info fetcher | ||
Options my also be provided as LP_API_ prefixed environment variables, e.g. LP_API_PORT=5000 is the same as --port=5000. | ||
` | ||
) | ||
.env("LP_API_") | ||
//.strict(true) | ||
.options({ | ||
port: { | ||
describe: "port to listen on", | ||
default: 3010, | ||
demandOption: true, | ||
type: "number", | ||
}, | ||
"own-region": { | ||
describe: "identify region in which this service runs (fra, mdw, etc)", | ||
type: "string", | ||
}, | ||
broadcaster: { | ||
describe: "broadcaster host:port to fetch info from", | ||
type: "string", | ||
default: "localhost:7935", | ||
}, | ||
"postgres-url": { | ||
describe: "url of a postgres database", | ||
type: "string", | ||
demandOption: true, | ||
}, | ||
}) | ||
.help() | ||
.parse(); | ||
return parsed as any as CamelKeys<typeof parsed>; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#!/usr/bin/env node | ||
|
||
import "./dotenv"; | ||
import makeApp from "./index"; | ||
import makeStreamInfoSvc from "./app/stream-info/stream-info-app"; | ||
import parseCli from "./parse-cli"; | ||
|
||
if (require.main === module) { | ||
const args = parseCli(); | ||
if (args.streamInfoService) { | ||
makeStreamInfoSvc(args); | ||
} else { | ||
makeApp(args); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,58 +1,8 @@ | ||
import "./dotenv"; | ||
import "source-map-support/register"; | ||
import makeApp from "./app/stream-info/stream-info-app"; | ||
import yargs from "yargs"; | ||
import path from "path"; | ||
import os from "os"; | ||
import { parseCli } from "./app/stream-info/parse-cli"; | ||
|
||
function parseCli() { | ||
return ( | ||
yargs | ||
.usage( | ||
` | ||
Livepeer Stream Info fetcher | ||
Options my also be provided as LP_API_ prefixed environment variables, e.g. LP_API_PORT=5000 is the same as --port=5000. | ||
` | ||
) | ||
.env("LP_API_") | ||
//.strict(true) | ||
.options({ | ||
port: { | ||
describe: "port to listen on", | ||
default: 3010, | ||
demandOption: true, | ||
type: "number", | ||
}, | ||
host: { | ||
describe: "host to bind to", | ||
type: "string", | ||
default: "localhost", | ||
}, | ||
"own-region": { | ||
describe: | ||
"identify region in which this service runs (fra, mdw, etc)", | ||
type: "string", | ||
}, | ||
broadcaster: { | ||
describe: "broadcaster host:port to fetch info from", | ||
type: "string", | ||
default: "127.0.0.1:7935", | ||
}, | ||
"postgres-url": { | ||
describe: "url of a postgres database", | ||
type: "string", | ||
demandOption: true, | ||
}, | ||
}) | ||
.help() | ||
.parse() | ||
); | ||
} | ||
|
||
function main() { | ||
require("dotenv").config(); | ||
if (require.main === module) { | ||
makeApp(parseCli()); | ||
} | ||
|
||
main(); |