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

Function runStart

src/cli/commands/start.ts:71–141  ·  view source on GitHub ↗
(options: StartOptions, passthrough: string[])

Source from the content-addressed store, hash-verified

69}
70
71export const runStart = async (options: StartOptions, passthrough: string[]): Promise<number> => {
72 ensureNotRoot()
73
74 const explicitPortFlag = process.argv.slice(2).some((arg) => arg === '--port' || arg.startsWith('--port='))
75 const hasPort = typeof options.port === 'number' && Number.isFinite(options.port)
76 if (explicitPortFlag && !hasPort) {
77 throw new Error('Port must be a safe integer between 1 and 65535')
78 }
79
80 if (hasPort) {
81 if (!Number.isSafeInteger(options.port) || options.port < 1 || options.port > 65535) {
82 throw new Error('Port must be a safe integer between 1 and 65535')
83 }
84 }
85
86 logStep('Preparing configuration')
87 ensureConfigBootstrap()
88
89 const composeFiles = ['docker-compose.yml']
90
91 if (options.tor) {
92 ensureTorDataDir()
93 composeFiles.push('docker-compose.tor.yml')
94 }
95
96 if (options.i2p) {
97 ensureI2PDataDir()
98 composeFiles.push('docker-compose.i2p.yml')
99 }
100
101 if (options.nginx) {
102 await ensureNginxBootstrap()
103 composeFiles.push('docker-compose.nginx.yml')
104 }
105
106 let overrideFile: string | undefined
107 if (hasPort) {
108 overrideFile = createPortOverrideComposeFile(options.port)
109 composeFiles.push(overrideFile)
110 }
111
112 const env: NodeJS.ProcessEnv = {}
113
114 if (options.debug) {
115 env.DEBUG = process.env.DEBUG || 'primary:*,worker:*,knex:*'
116 }
117
118 const spinner = ora('Starting relay...').start()
119 const composePassthrough = passthrough.filter((arg) => arg !== '--')
120 const upArgs = ['up', '--build', '--remove-orphans', ...(options.detach ? ['-d'] : []), ...composePassthrough]
121
122 try {
123 const code = await runDockerCompose({
124 files: composeFiles,
125 args: upArgs,
126 env,
127 })
128

Callers 5

index.tsFile · 0.90
runStartMenuFunction · 0.90
runUpdateFunction · 0.90
restartRelayFunction · 0.90
runSetupFunction · 0.90

Calls 8

ensureNotRootFunction · 0.90
logStepFunction · 0.90
ensureConfigBootstrapFunction · 0.90
ensureTorDataDirFunction · 0.90
ensureI2PDataDirFunction · 0.90
runDockerComposeFunction · 0.90
ensureNginxBootstrapFunction · 0.85

Tested by

no test coverage detected