( args: DefaultedArgs, )
| 120 | } |
| 121 | |
| 122 | export 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 | } |
no test coverage detected