MCPcopy Index your code
hub / github.com/cameri/nostream / App

Class App

src/app/app.ts:16–172  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

14const logger = createLogger('app-primary')
15
16export class App implements IRunnable {
17 private workers: WeakMap<Worker, Record<string, string>>
18 private watchers: FSWatcher[] | undefined
19
20 public constructor(
21 private readonly process: NodeJS.Process,
22 private readonly cluster: Cluster,
23 private readonly settings: () => Settings,
24 ) {
25 logger('starting')
26
27 this.workers = new WeakMap()
28
29 this.cluster.on('message', this.onClusterMessage.bind(this)).on('exit', this.onClusterExit.bind(this))
30
31 this.process.on('SIGTERM', this.onExit.bind(this))
32
33 logger('started')
34 }
35
36 public run(): void {
37 const settings = this.settings()
38 this.watchers = SettingsStatic.watchSettings()
39 logger.info(`
40 ███▄ █ ▒█████ ██████ ▄▄▄█████▓ ██▀███ ▓█████ ▄▄▄ ███▄ ▄███▓
41 ██ ▀█ █ ▒██▒ ██▒▒██ ▒ ▓ ██▒ ▓▒▓██ ▒ ██▒▓█ ▀▒████▄ ▓██▒▀█▀ ██▒
42▓██ ▀█ ██▒▒██░ ██▒░ ▓██▄ ▒ ▓██░ ▒░▓██ ░▄█ ▒▒███ ▒██ ▀█▄ ▓██ ▓██░
43▓██▒ ▐▌██▒▒██ ██░ ▒ ██▒░ ▓██▓ ░ ▒██▀▀█▄ ▒▓█ ▄░██▄▄▄▄██ ▒██ ▒██
44▒██░ ▓██░░ ████▓▒░▒██████▒▒ ▒██▒ ░ ░██▓ ▒██▒░▒████▒▓█ ▓██▒▒██▒ ░██▒
45░ ▒░ ▒ ▒ ░ ▒░▒░▒░ ▒ ▒▓▒ ▒ ░ ▒ ░░ ░ ▒▓ ░▒▓░░░ ▒░ ░▒▒ ▓▒█░░ ▒░ ░ ░
46░ ░░ ░ ▒░ ░ ▒ ▒░ ░ ░▒ ░ ░ ░ ░▒ ░ ▒░ ░ ░ ░ ▒ ▒▒ ░░ ░ ░
47 ░ ░ ░ ░ ░ ░ ▒ ░ ░ ░ ░ ░░ ░ ░ ░ ▒ ░ ░
48 ░ ░ ░ ░ ░ ░ ░ ░ ░ ░`)
49 const width = 74
50 const torHiddenServicePort = process.env.HIDDEN_SERVICE_PORT ? Number(process.env.HIDDEN_SERVICE_PORT) : 80
51 const port = process.env.RELAY_PORT ? Number(process.env.RELAY_PORT) : 8008
52
53 const logCentered = (input: string, width: number) => {
54 const start = (width - input.length) >> 1
55 logger.info(' '.repeat(start), input)
56 }
57 logCentered(`v${packageJson.version}`, width)
58 logCentered(`NIPs implemented: ${packageJson.supportedNips}`, width)
59 const paymentsEnabled = pathEq(['payments', 'enabled'], true, settings)
60 logCentered(`Pay-to-relay ${paymentsEnabled ? 'enabled' : 'disabled'}`, width)
61 if (paymentsEnabled) {
62 logCentered(`Payments provider: ${path(['payments', 'processor'], settings)}`, width)
63 }
64
65 if (
66 paymentsEnabled &&
67 (typeof this.process.env.SECRET !== 'string' ||
68 this.process.env.SECRET === '' ||
69 this.process.env.SECRET === 'changeme')
70 ) {
71 logger.error('Please configure the secret using the SECRET environment variable.')
72 this.process.exit(1)
73 }

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected