Add native Windows Service support to sai-builder#1
Add native Windows Service support to sai-builder#1google-labs-jules[bot] wants to merge 9 commits intomainfrom
Conversation
- sai-power: Manages Power Controllers (PCONs) and their dependencies. Accepts builder registrations via WebSocket to learn topology. Defaults PCONs to ON if no builders registered (cold start). - sai-builder: Connects to sai-power via WebSocket to register PCON binding and platforms. - sai-server: Receives PCON topology from sai-power, persists it to DB (schema updates handled), and serves it to Web UI. - Web UI: Updated to render PCONs with nested builders. - Fixes: SQL syntax error in server, JS reference error in frontend, linker error for saip_switch, and memory leaks in builder handling.
Refactors the main application loop into `saib_app_run` to allow execution from a service context. Adds `b-win32-service.c` to implement Windows Service API hooks (`ServiceMain`, `ServiceCtrlHandler`). Updates `CMakeLists.txt` to include the service support on Windows builds. Ensures command-line arguments are propagated correctly when running as a service.
|
👋 Jules, reporting for duty! I'm here to lend a hand with this pull request. When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down. I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job! For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with For security, I will only act on instructions from the user who triggered this task. New to Jules? Learn more at jules.google/docs. |
Adds src/builder/README.Windows.md detailing how to build, create the user, grant necessary privileges, and register sai-builder as a Windows Service.
Adds a PowerShell script method to README.Windows.md for granting `SeShutdownPrivilege` and `SeServiceLogonRight` on Windows Home editions where `secpol.msc` is unavailable. This ensures the documentation is actionable for users on all Windows editions.
Adds a section on granting file permissions using `icacls` to ensure the service user has access to build artifacts and configuration files, preventing 'Access is denied' errors.
Updates CMakeLists.txt to include `BundleUtilities` for automatic DLL copying (e.g., libwebsockets, OpenSSL) during installation on Windows. Updates README.Windows.md to instruct users to perform a system-wide install via `cmake --install`, solving dependency and permission issues for the service user.
Moves the DLL bundling step (fixup_bundle) to run after the executable install step in CMakeLists.txt. This ensures the executable exists in the install directory before bundle utilities try to resolve its dependencies.
Separates the lock directory check from the mirror directory creation in the Windows git helper batch script. This prevents an infinite loop where existing mirror directories were falsely interpreted as a lock failure. Also ensures `timeout.exe` is replaced with `ping` for service compatibility.
Updates the git helper batch script to include Git and System paths in PATH, ensuring git can be found. Also refines the lock waiting logic to be more robust.
This change enables
sai-builderto run as a native Windows Service. This allows the builder to be managed via the Windows Service Control Manager (SCM) and configured to run as a specific unprivileged user (e.g.,.\sai) from startup, resolving issues related to git fetch failures and environment consistency seen when running manually.Key changes:
src/builder/b-sai.c: Extractedmainlogic intosaib_app_run. Addedsaib_app_stop.src/builder/b-win32-service.c: New file implementing the Service API. It capturesargc/argvfrommainto pass tosaib_app_run, preserving configuration flags.src/builder/CMakeLists.txt: Addedb-win32-service.cto sources.src/builder/b-private.h: Added declarations for new functions.PR created automatically by Jules for task 3950684034801294178 started by @lws-team