pub fn detect_from_process(process_name: &str) -> Option<StackLabel>Expand description
Detect a stack label from a process executable name.
Matching is ASCII case-insensitive. A trailing Windows .exe suffix is
ignored before matching, so NGINX.EXE and nginx produce the same label.
Two relaxations apply when the exact name is unknown:
- A trailing version made of digits and dots is ignored for runtime names,
so
python3.12,php8.2,php-fpm8.2,ruby3.2, andnode20match. - Processes that set a title which Linux truncates to 15 characters match
on the word before the first space or colon:
next-server (v1isNext.js,puma 6.4.2 (tcandpuma: cluster warePuma, andgunicorn: masteisGunicorn.
§Examples
use what_stack::detect_from_process;
use what_stack::StackKind;
let python = detect_from_process("python3").expect("known runtime");
assert_eq!(python, "Python");
assert_eq!(python.kind(), StackKind::Runtime);
assert_eq!(detect_from_process("python3.12").expect("versioned runtime"), "Python");
assert_eq!(detect_from_process("next-server (v1").expect("titled"), "Next.js");
assert_eq!(detect_from_process("gunicorn: maste").expect("titled"), "Gunicorn");
assert_eq!(detect_from_process("NGINX.EXE").expect("known server"), "Nginx");
assert_eq!(detect_from_process("node-exporter"), None);§Limits
This function does not inspect command-line arguments or project files.
Use StackDetector when process names should be
combined with project config and image metadata.