launcher, server: one hidden-command helper per crate, server children keep its terminal
- horizon-bench reads the machine with horizon-telemetry's `command_output` (now public) instead of a second copy of it; the console flag lives in one place. - horizon-server's `process::command` hides the console only when the server has none (started by the launcher). Run from a terminal, `schtasks`, `tar` and `mklink` share it as before, so their output still reaches it: a CREATE_NO_WINDOW child can't write to its parent's console. - horizon-prepare's java/javac keep the stdin they had; only the console flag is new. - launcher `process::hide_console` returns the command (no `let _ =` on other systems); the machine-details thread failing just leaves the report without them, as a slow one does. - README: the Windows subsystem's effect on the command line (interactive cmd/PowerShell don't wait or set the exit code) under "Command line", the deferred probe under "Performance log". Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -1,8 +1,7 @@
|
||||
//! The machine a report was measured on. CPU, RAM and OS are detected here; the GPU and the display
|
||||
//! come from the program that rendered (the game knows its adapter, the launcher its window).
|
||||
|
||||
use std::process::Command;
|
||||
|
||||
use horizon_telemetry::system::command_output as output;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
|
||||
@@ -173,20 +172,6 @@ pub fn cpu_seconds(pid: u32) -> Option<f64> {
|
||||
Some(ticks / 100.0)
|
||||
}
|
||||
|
||||
fn output(program: &str, args: &[&str]) -> Option<String> {
|
||||
let mut command = Command::new(program);
|
||||
command.args(args);
|
||||
#[cfg(windows)]
|
||||
{
|
||||
use std::os::windows::process::CommandExt;
|
||||
const CREATE_NO_WINDOW: u32 = 0x0800_0000;
|
||||
command.creation_flags(CREATE_NO_WINDOW);
|
||||
}
|
||||
let out = command.output().ok()?;
|
||||
let text = String::from_utf8(out.stdout).ok()?.trim().to_owned();
|
||||
(out.status.success() && !text.is_empty()).then_some(text)
|
||||
}
|
||||
|
||||
#[cfg(target_os = "macos")]
|
||||
fn os_version() -> Option<String> {
|
||||
output("sw_vers", &["-productVersion"])
|
||||
|
||||
@@ -14,16 +14,17 @@ pub struct Jdk {
|
||||
|
||||
const TIMEOUT: Duration = Duration::from_secs(3600);
|
||||
|
||||
/// Exporters and JDK probes write to pipes or log files, never to a new terminal.
|
||||
/// Exporters and JDK probes write to pipes or log files: on Windows they open no terminal.
|
||||
fn command(program: impl AsRef<OsStr>) -> Command {
|
||||
let mut command = Command::new(program);
|
||||
command.stdin(Stdio::null());
|
||||
let command = Command::new(program);
|
||||
#[cfg(windows)]
|
||||
{
|
||||
let command = {
|
||||
use std::os::windows::process::CommandExt;
|
||||
const CREATE_NO_WINDOW: u32 = 0x0800_0000;
|
||||
let mut command = command;
|
||||
command.creation_flags(CREATE_NO_WINDOW);
|
||||
}
|
||||
command
|
||||
};
|
||||
command
|
||||
}
|
||||
|
||||
|
||||
@@ -1,18 +1,20 @@
|
||||
//! Background helpers inherit their log streams without opening a Windows terminal.
|
||||
//! The programs the server runs. Started by the launcher, the server has no console, and each
|
||||
//! console program it started would open a terminal window on Windows: those open none. Run from
|
||||
//! a terminal, they share it, so what they print still reaches it.
|
||||
use std::{ffi::OsStr, process::Command};
|
||||
|
||||
pub fn command(program: impl AsRef<OsStr>) -> Command {
|
||||
let mut command = Command::new(program);
|
||||
configure(&mut command);
|
||||
let command = Command::new(program);
|
||||
#[cfg(windows)]
|
||||
let command = {
|
||||
use std::os::windows::process::CommandExt;
|
||||
use windows_sys::Win32::System::{Console::GetConsoleWindow, Threading::CREATE_NO_WINDOW};
|
||||
let mut command = command;
|
||||
// SAFETY: no arguments; it returns this process's console window or null.
|
||||
if unsafe { GetConsoleWindow() }.is_null() {
|
||||
command.creation_flags(CREATE_NO_WINDOW);
|
||||
}
|
||||
command
|
||||
};
|
||||
command
|
||||
}
|
||||
|
||||
fn configure(command: &mut Command) {
|
||||
#[cfg(windows)]
|
||||
{
|
||||
use std::os::windows::process::CommandExt;
|
||||
command.creation_flags(windows_sys::Win32::System::Threading::CREATE_NO_WINDOW);
|
||||
}
|
||||
#[cfg(not(windows))]
|
||||
let _ = command;
|
||||
}
|
||||
|
||||
@@ -9,7 +9,10 @@ use std::sync::OnceLock;
|
||||
|
||||
use crate::payload::System;
|
||||
|
||||
fn command_output(program: &str, args: &[&str]) -> Option<String> {
|
||||
/// What `program args` prints, trimmed, when it succeeds and prints something. On Windows the
|
||||
/// program opens no console window: a GUI launcher or a game started without one would flash a
|
||||
/// terminal for every probe.
|
||||
pub fn command_output(program: &str, args: &[&str]) -> Option<String> {
|
||||
let mut command = std::process::Command::new(program);
|
||||
command.args(args);
|
||||
#[cfg(windows)]
|
||||
|
||||
+8
-9
@@ -97,12 +97,6 @@ page `servers.json` (the list), `servers/<name>/` (the servers created there) an
|
||||
Long pages, dialogs, the server console and data previews have a visible scrollbar when
|
||||
their content overflows. Drag the thumb or click the track to navigate without a mouse wheel.
|
||||
|
||||
On Windows, desktop launches and background tools run without terminal windows. Preparation
|
||||
and server logs still reach the launcher, and CLI commands keep their terminal or redirected
|
||||
input and output, including MCP.
|
||||
Hardware details for performance reports are collected in the background after the first
|
||||
frame, so Windows hardware queries do not delay the window opening.
|
||||
|
||||
## Updates
|
||||
|
||||
The launcher looks for a newer Horizon release when it starts and every 30 minutes while it
|
||||
@@ -133,7 +127,12 @@ and `horizon-launcher-windows-x64.zip`, never marked latest. The version is buil
|
||||
|
||||
## Command line
|
||||
|
||||
The same binary is a command-line tool; without a subcommand it opens the window.
|
||||
The same binary is a command-line tool; without a subcommand it opens the window. On Windows it
|
||||
is a windowed program, so a desktop start opens no terminal; a subcommand writes to the terminal
|
||||
it was typed in, or to the pipes and files it was given (MCP keeps its stdio). Interactive `cmd`
|
||||
and PowerShell don't wait for a windowed program: they show the prompt again before its output
|
||||
and don't set `%ERRORLEVEL%` / `$LASTEXITCODE`. Scripts that need the exit code use
|
||||
`start /wait horizon-launcher …` or `Start-Process -Wait`, or read its output through a pipe.
|
||||
|
||||
horizon-launcher versions [--installed] releases on GitHub, or what is installed (* = selected)
|
||||
horizon-launcher install <tag|latest>
|
||||
@@ -256,8 +255,8 @@ Each session writes its own measurements to `benchmarks/launcher-<time>-session.
|
||||
launcher's data folder, in the [benchmark report format](../docs/benchmark-report.md): start to the
|
||||
first frame, the release list fetch, installs and updates (download and unpack), preparing, Play to
|
||||
the game's first frame, memory, UI frame times and the binary's size, with the machine's CPU, RAM
|
||||
and OS. Attach it to an issue about the launcher being slow. `horizon-launcher benchmark` measures
|
||||
on purpose: it starts the launcher `--repeats` times (5; the first start is the cold one, as far
|
||||
and OS (read on a thread after the first frame: on Windows those queries take seconds). Attach it
|
||||
to an issue about the launcher being slow. `horizon-launcher benchmark` measures on purpose: it starts the launcher `--repeats` times (5; the first start is the cold one, as far
|
||||
as the OS's file cache allows), switches pages for a few seconds in each, rests 3 seconds to
|
||||
measure idle CPU, fetches the release list 3 times, and writes one report there with means and
|
||||
95% confidence intervals. Its window has to be on a screen that is awake. Session logs stay on
|
||||
|
||||
@@ -160,6 +160,7 @@ impl Perf {
|
||||
&self.report
|
||||
}
|
||||
|
||||
/// Takes the machine's details into the report once their thread has them.
|
||||
fn poll_hardware(&mut self) {
|
||||
let Some(receiver) = &self.hardware else {
|
||||
return;
|
||||
@@ -173,12 +174,7 @@ impl Perf {
|
||||
self.dirty = true;
|
||||
}
|
||||
Err(TryRecvError::Empty) => {}
|
||||
Err(TryRecvError::Disconnected) => {
|
||||
self.hardware = None;
|
||||
eprintln!(
|
||||
"The launcher could not collect its performance report's machine details."
|
||||
);
|
||||
}
|
||||
Err(TryRecvError::Disconnected) => self.hardware = None,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,22 +1,21 @@
|
||||
//! Background commands keep their configured streams without opening Windows consoles.
|
||||
//! The programs the launcher runs in the background: on Windows they open no console window
|
||||
//! (the launcher has none to share), and keep the streams their caller gives them.
|
||||
use std::ffi::OsStr;
|
||||
use std::process::Command;
|
||||
|
||||
/// Builds a background command. Callers still choose how to capture its input and output.
|
||||
pub fn command(program: impl AsRef<OsStr>) -> Command {
|
||||
let mut command = Command::new(program);
|
||||
hide_console(&mut command);
|
||||
command
|
||||
}
|
||||
|
||||
/// Hides a background command's console on Windows, preserving its configured standard streams.
|
||||
pub fn hide_console(command: &mut Command) {
|
||||
/// [`command`] for a `Command` made elsewhere.
|
||||
pub fn hide_console(command: &mut Command) -> &mut Command {
|
||||
#[cfg(windows)]
|
||||
{
|
||||
use std::os::windows::process::CommandExt;
|
||||
const CREATE_NO_WINDOW: u32 = 0x0800_0000;
|
||||
command.creation_flags(CREATE_NO_WINDOW);
|
||||
}
|
||||
#[cfg(not(windows))]
|
||||
let _ = command;
|
||||
command
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user