Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,17 @@ jobs:
- run: rm -rf .cargo
- uses: Swatinem/rust-cache@e18b497796c12c097a38f9edb9d0641fb99eee32 # v2
- run: mise run ci

windows-build:
runs-on: windows-latest
timeout-minutes: 20
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
with:
submodules: true
- uses: Swatinem/rust-cache@e18b497796c12c097a38f9edb9d0641fb99eee32 # v2
# `cargo check` (debug) catches the compile errors that otherwise only
# surface in the release pipeline, without paying for an optimized link.
# Integration tests under tests/ are Unix-only (lsof, pkill, etc.) so
# we limit the check to lib + bins.
- run: cargo check --lib --bins --all-features
Comment on lines +38 to +43

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Missing Rust toolchain setup step

The windows-build job relies on the Rust version that happens to be pre-installed on the windows-latest runner. Cargo.toml declares rust-version = "1.87", but GitHub's hosted runners ship whatever Rust stable was current when the image was built — that may lag behind. Adding an explicit dtolnay/rust-toolchain action (or similar) ensures the Windows job uses the same pinned version managed by mise on the Linux job and prevents silent version drift.

Fix in Claude Code

33 changes: 26 additions & 7 deletions src/config_types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -197,13 +197,32 @@ impl JsonSchema for CpuLimit {
#[serde(try_from = "String")]
pub struct StopSignal(i32);

// Signal numbers. On Unix we pull them from `libc` so they match the platform
// (SIGUSR1/2 differ between Linux and BSD/macOS). On Windows the values are
// only used for parsing and Display — `procs::kill` ignores `stop_signal` and
// uses TerminateProcess via sysinfo — so POSIX-typical Linux values are fine.
#[cfg(unix)]
use libc::{SIGHUP, SIGINT, SIGQUIT, SIGTERM, SIGUSR1, SIGUSR2};
#[cfg(windows)]
const SIGHUP: i32 = 1;
#[cfg(windows)]
const SIGINT: i32 = 2;
#[cfg(windows)]
const SIGQUIT: i32 = 3;
#[cfg(windows)]
const SIGTERM: i32 = 15;
#[cfg(windows)]
const SIGUSR1: i32 = 10;
#[cfg(windows)]
const SIGUSR2: i32 = 12;

const SIGNAL_TABLE: &[(&str, i32)] = &[
("HUP", libc::SIGHUP),
("INT", libc::SIGINT),
("QUIT", libc::SIGQUIT),
("TERM", libc::SIGTERM),
("USR1", libc::SIGUSR1),
("USR2", libc::SIGUSR2),
("HUP", SIGHUP),
("INT", SIGINT),
("QUIT", SIGQUIT),
("TERM", SIGTERM),
("USR1", SIGUSR1),
("USR2", SIGUSR2),
];

impl StopSignal {
Expand All @@ -218,7 +237,7 @@ impl StopSignal {

impl Default for StopSignal {
fn default() -> Self {
Self(libc::SIGTERM)
Self(SIGTERM)
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/deps.rs
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ pub fn compute_reverse_stop_order_with_config(
mod tests {
use super::*;
use crate::daemon_id::DaemonId;
use crate::pitchfork_toml::{PitchforkTomlDaemon, Retry};
use crate::pitchfork_toml::PitchforkTomlDaemon;
use indexmap::IndexMap;

// Helper to build a test daemon with only `depends` set, all other fields default/None.
Expand Down
1 change: 1 addition & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ mod watch_files;
mod web;

pub use miette::Result;
#[cfg(unix)]
use tokio::signal;
#[cfg(unix)]
use tokio::signal::unix::SignalKind;
Expand Down
4 changes: 3 additions & 1 deletion src/procs.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use crate::Result;
#[cfg(unix)]
use crate::settings::settings;
use miette::IntoDiagnostic;
use once_cell::sync::Lazy;
Expand Down Expand Up @@ -212,11 +213,12 @@ impl Procs {

#[cfg(windows)]
{
let _ = (stop_signal, stop_timeout);
if let Some(process) = self.lock_system().process(sysinfo_pid) {
process.kill();
process.wait();
}
return Ok(true);
Ok(true)
}

#[cfg(unix)]
Expand Down
4 changes: 2 additions & 2 deletions src/proxy/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -464,9 +464,9 @@ pub fn generate_ca(cert_path: &std::path::Path, key_path: &std::path::Path) -> c
// Using OpenOptions + mode() so the file is never world-readable,
// even briefly before a chmod call.
{
use std::io::Write;
#[cfg(unix)]
{
use std::io::Write;
use std::os::unix::fs::OpenOptionsExt;
std::fs::OpenOptions::new()
.write(true)
Expand Down Expand Up @@ -809,9 +809,9 @@ impl SniCertResolver {
let disk_path = self.host_certs_dir.join(format!("{safe_name}.pem"));
let combined_pem = format!("{}{}", leaf_cert.pem(), key_pem);
{
use std::io::Write;
#[cfg(unix)]
{
use std::io::Write;
use std::os::unix::fs::OpenOptionsExt;
if let Err(e) = std::fs::OpenOptions::new()
.write(true)
Expand Down
1 change: 0 additions & 1 deletion src/state_file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,6 @@ fn normalized_lock_path(path: &Path) -> PathBuf {
mod tests {
use super::*;
use crate::daemon_status::DaemonStatus;
use crate::pitchfork_toml::Retry;

#[test]
fn test_state_file_toml_roundtrip_stopped() {
Expand Down
5 changes: 4 additions & 1 deletion src/supervisor/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ mod autostop;
mod hooks;
mod ipc_handlers;
mod lifecycle;
#[cfg(unix)]
mod pty;
mod retry;
mod state;
Expand All @@ -29,7 +30,9 @@ use crate::{Result, env};
use duct::cmd;
use miette::IntoDiagnostic;
use once_cell::sync::Lazy;
use std::collections::{HashMap, HashSet};
use std::collections::HashMap;
#[cfg(unix)]
use std::collections::HashSet;
use std::fs;
#[cfg(unix)]
use std::os::unix::fs::PermissionsExt;
Expand Down
1 change: 0 additions & 1 deletion src/supervisor/pty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ pub struct PtyPair {
/// practice — the extra fd is simply unused — but if strict
/// close-on-exec semantics are needed, set `FD_CLOEXEC` manually via
/// `fcntl(fd, F_SETFD, FD_CLOEXEC)`.
#[cfg(unix)]
pub fn openpty() -> std::io::Result<PtyPair> {
let mut master_fd: libc::c_int = -1;
let mut slave_fd: libc::c_int = -1;
Expand Down
3 changes: 3 additions & 0 deletions src/web/routes/logs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -389,6 +389,7 @@ pub async fn stream_sse(
let mut file_handle: Option<std::fs::File> = None;

// Internal result type for file operations within spawn_blocking
#[allow(dead_code)] // FileRotated is constructed only on Unix
enum FileOpResult {
Data(Vec<u8>),
Truncated,
Expand Down Expand Up @@ -417,8 +418,10 @@ pub async fn stream_sse(
let fh = file_handle.take();
let mut ls = last_size;
let prev_ino = last_path_ino;
#[cfg_attr(not(unix), allow(unused_variables))]
let poll_count = poll_count;
tokio::task::spawn_blocking(move || {
#[cfg_attr(not(unix), allow(unused_variables))]
let opened_fresh = fh.is_none();
Comment on lines +421 to 425

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Prefer _-prefix over cfg_attr for unused-variable suppression

#[cfg_attr(not(unix), allow(unused_variables))] on a let statement is uncommon and easy to misread. Since both poll_count and opened_fresh are only consumed inside #[cfg(unix)] blocks, the simpler and more idiomatic way to silence the warning on non-Unix targets is to use a leading underscore in the binding itself (let _poll_count = poll_count;), which requires no attribute at all.

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

Fix in Claude Code

let mut file = match fh {
Some(f) => f,
Expand Down
Loading