tail.rs 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. //! Builds the "tail" of the docker command — everything after the image
  2. //! name (entrypoint, model, args, auto-generated flags).
  3. use crate::config::{Node, Recipe};
  4. use crate::engine_flags::{EngineFlagsCtx, build_engine_args};
  5. /// The subset of [`DockerCommandCtx`] that `build_tail` needs.
  6. pub(crate) struct TailCtx<'a> {
  7. pub recipe: &'a Recipe,
  8. pub tp_size: u32,
  9. pub pp_size: u32,
  10. pub nnodes: u32,
  11. pub init_port: u16,
  12. pub master_ib_ip: &'a str,
  13. }
  14. /// Build the docker command tail — everything after the image name.
  15. pub fn build_tail(ctx: &TailCtx<'_>, node: &Node) -> Vec<String> {
  16. let mut tail = Vec::new();
  17. // Entrypoint — from the recipe (e.g. ["vllm", "serve"]), returned raw.
  18. // Callers shell-quote the assembled command (Docker host side) or pass
  19. // to `build_mod_script` (which quotes each word for the container `-c`).
  20. if !ctx.recipe.entrypoint.is_empty() {
  21. tail.extend(ctx.recipe.entrypoint.clone());
  22. }
  23. // Shared engine args: model, recipe args, distributed flags, headless.
  24. let ectx = EngineFlagsCtx {
  25. recipe: ctx.recipe,
  26. tp_size: ctx.tp_size,
  27. pp_size: ctx.pp_size,
  28. nnodes: ctx.nnodes,
  29. init_port: ctx.init_port,
  30. master_ib_ip: ctx.master_ib_ip,
  31. };
  32. tail.extend(build_engine_args(&ectx, node));
  33. // Docker always binds --host 0.0.0.0 and --port.
  34. tail.push("--host".to_string());
  35. tail.push("0.0.0.0".to_string());
  36. tail.extend(["--port".into(), ctx.recipe.port.to_string()]);
  37. tail
  38. }