feat: support to run windows binary as service (#7153)

* feat: support to run windows binary as service

* ee ref

* ee ref

* flags

* Update backend/src/main.rs

Co-authored-by: claude[bot] <209825114+claude[bot]@users.noreply.github.com>

* fix ai commit

* fix

* ee ref

---------

Co-authored-by: claude[bot] <209825114+claude[bot]@users.noreply.github.com>
Co-authored-by: Ruben Fiszel <ruben@windmill.dev>
This commit is contained in:
Alexander Petric
2025-11-17 06:48:31 -05:00
committed by GitHub
parent 9add877047
commit ceeff5f76c
4 changed files with 33 additions and 1 deletions
+13
View File
@@ -15204,6 +15204,8 @@ dependencies = [
"windmill-indexer",
"windmill-queue",
"windmill-worker",
"windows-service",
"windows-sys 0.52.0",
]
[[package]]
@@ -16089,6 +16091,17 @@ dependencies = [
"windows-link 0.2.1",
]
[[package]]
name = "windows-service"
version = "0.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d24d6bcc7f734a4091ecf8d7a64c5f7d7066f45585c1861eba06449909609c8a"
dependencies = [
"bitflags 2.9.4",
"widestring",
"windows-sys 0.52.0",
]
[[package]]
name = "windows-strings"
version = "0.4.2"
+4
View File
@@ -161,6 +161,10 @@ nom.workspace = true
globset.workspace = true
[target.'cfg(windows)'.dependencies]
windows-service = "0.7"
windows-sys = { version = "0.52", features = ["Win32_System_Services", "Win32_System_Console", "Win32_Foundation"] }
[target.'cfg(not(target_env = "msvc"))'.dependencies]
tikv-jemallocator = { optional = true, workspace = true }
tikv-jemalloc-sys = { optional = true, workspace = true }
+1 -1
View File
@@ -1 +1 @@
423c3c2d175b15b7c0f010e08f1848a7710e31be
41e693c08aa096a0d2e9a76a4ebe9b4149bdde24
+15
View File
@@ -113,6 +113,10 @@ pub mod ee;
mod ee_oss;
mod monitor;
// Windows service support - EE feature
#[cfg(all(windows, feature = "enterprise", feature = "private"))]
mod windows_service_ee;
pub fn setup_deno_runtime() -> anyhow::Result<()> {
// https://github.com/denoland/deno/blob/main/cli/main.rs#L477
#[cfg(feature = "deno_core")]
@@ -207,6 +211,17 @@ lazy_static::lazy_static! {
}
pub fn main() -> anyhow::Result<()> {
// On Windows with enterprise feature, check if running as a service
#[cfg(all(windows, feature = "enterprise", feature = "private"))]
{
if windows_service_ee::is_running_as_service() {
// Run as Windows service with SCM handlers
return windows_service_ee::run_as_windows_service()
.map_err(|e| anyhow::anyhow!("Failed to run as Windows service: {}", e));
}
}
// Normal execution (console/foreground mode)
setup_deno_runtime()?;
create_and_run_current_thread_inner(windmill_main())
}