Start a server to run the given wasi-http proxy component
(mut self)
| 184 | impl ServeCommand { |
| 185 | /// Start a server to run the given wasi-http proxy component |
| 186 | pub fn execute(mut self) -> Result<()> { |
| 187 | self.run.common.init_logging()?; |
| 188 | |
| 189 | // We force cli errors before starting to listen for connections so then |
| 190 | // we don't accidentally delay them to the first request. |
| 191 | |
| 192 | if self.run.common.wasi.nn == Some(true) { |
| 193 | #[cfg(not(feature = "wasi-nn"))] |
| 194 | { |
| 195 | bail!("Cannot enable wasi-nn when the binary is not compiled with this feature."); |
| 196 | } |
| 197 | } |
| 198 | |
| 199 | if self.run.common.wasi.threads == Some(true) { |
| 200 | bail!("wasi-threads does not support components yet") |
| 201 | } |
| 202 | |
| 203 | // The serve command requires both wasi-http and the component model, so |
| 204 | // we enable those by default here. |
| 205 | if self.run.common.wasi.http.replace(true) == Some(false) { |
| 206 | bail!("wasi-http is required for the serve command, and must not be disabled"); |
| 207 | } |
| 208 | if self.run.common.wasm.component_model.replace(true) == Some(false) { |
| 209 | bail!("components are required for the serve command, and must not be disabled"); |
| 210 | } |
| 211 | |
| 212 | let runtime = tokio::runtime::Builder::new_multi_thread() |
| 213 | .enable_time() |
| 214 | .enable_io() |
| 215 | .build()?; |
| 216 | |
| 217 | runtime.block_on(self.serve())?; |
| 218 | |
| 219 | Ok(()) |
| 220 | } |
| 221 | |
| 222 | /// Set up the debugger component side-car, mirroring |
| 223 | /// [`RunCommand::debugger_run`]. |