MCPcopy Index your code
hub / github.com/coder/code-server / runCodeServer

Function runCodeServer

src/node/main.ts:122–245  ·  view source on GitHub ↗
(
  args: DefaultedArgs,
)

Source from the content-addressed store, hash-verified

120}
121
122export const runCodeServer = async (
123 args: DefaultedArgs,
124): Promise<{ dispose: Disposable["dispose"]; server: http.Server }> => {
125 logger.info(`code-server ${version} ${commit}`)
126
127 // Load custom strings if provided
128 if (args.i18n) {
129 await loadCustomStrings(args.i18n)
130 logger.info("Loaded custom strings")
131 }
132
133 logger.info(`Using user-data-dir ${args["user-data-dir"]}`)
134 logger.debug(`Using extensions-dir ${args["extensions-dir"]}`)
135
136 if (args.auth === AuthType.Password && !args.password && !args["hashed-password"]) {
137 throw new Error(
138 "Please pass in a password via the config file or environment variable ($PASSWORD or $HASHED_PASSWORD)",
139 )
140 }
141
142 const app = await createApp(args)
143 const protocol = args.cert ? "https" : "http"
144 const serverAddress = ensureAddress(app.server, protocol)
145 const { disposeRoutes, heart } = await register(app, args)
146
147 logger.info(`Using config file ${args.config}`)
148 logger.info(`${protocol.toUpperCase()} server listening on ${serverAddress.toString()}`)
149 if (args.auth === AuthType.Password) {
150 logger.info(" - Authentication is enabled")
151 if (args.usingEnvPassword) {
152 logger.info(" - Using password from $PASSWORD")
153 } else if (args.usingEnvHashedPassword) {
154 logger.info(" - Using password from $HASHED_PASSWORD")
155 } else if (args["hashed-password"]) {
156 logger.info(` - Using hashed-password from ${args.config}`)
157 } else {
158 logger.info(` - Using password from ${args.config}`)
159 }
160 } else {
161 logger.info(" - Authentication is disabled")
162 }
163
164 if (args.cert) {
165 logger.info(` - Using certificate for HTTPS: ${args.cert.value}`)
166 } else {
167 logger.info(" - Not serving HTTPS")
168 }
169
170 if (args["idle-timeout-seconds"]) {
171 logger.info(` - Idle timeout set to ${args["idle-timeout-seconds"]} seconds`)
172
173 let idleShutdownTimer: NodeJS.Timeout | undefined
174 const startIdleShutdownTimer = () => {
175 idleShutdownTimer = setTimeout(() => {
176 logger.warn(`Idle timeout of ${args["idle-timeout-seconds"]} seconds exceeded`)
177 wrapper.exit(0)
178 }, args["idle-timeout-seconds"]! * 1000)
179 }

Callers 2

setupFunction · 0.90
entryFunction · 0.90

Calls 9

loadCustomStringsFunction · 0.90
createAppFunction · 0.90
ensureAddressFunction · 0.90
registerFunction · 0.90
pluralFunction · 0.90
openFunction · 0.90
startIdleShutdownTimerFunction · 0.85
disposeMethod · 0.65
addressMethod · 0.45

Tested by

no test coverage detected