Skip to content

Conversation

@adcondev
Copy link
Owner

This pull request refactors the BasculaServicio project to run as a proper Windows service, using the go-svc library for lifecycle management. It also introduces scripts for installing, uninstalling, and managing the service, improves logging, and sets the default to "test mode" for easier development and debugging.

Key changes include:

Service Daemonization & Lifecycle Management:

  • Refactored the main application to implement the svc.Service interface using the go-svc library, enabling the program to run as a Windows service with proper start/stop handling and signal management. (cmd/BasculaServicio/main.go [1] [2]
  • Added a Program struct with Init, Start, and Stop methods to manage service lifecycle, including graceful shutdown and goroutine management. (cmd/BasculaServicio/main.go [1] [2]

Logging Improvements:

  • Configured the service to write logs to a file in the %PROGRAMDATA%\BasculaServicio\service.log directory, ensuring logs are persisted and accessible for troubleshooting. (cmd/BasculaServicio/main.go cmd/BasculaServicio/main.goL334-R410)

Configuration & Defaults:

  • Set the default configuration to enable "ModoPrueba" (test mode) by default, facilitating easier development and testing. (cmd/BasculaServicio/main.go cmd/BasculaServicio/main.goL31-R83)
  • Updated the web configuration UI to have the "Modo prueba" checkbox checked by default. (web/html/index_config.html web/html/index_config.htmlL15-R15)

Build & Service Management Scripts:

  • Added install.bat and uninstall.bat scripts for easy installation and removal of the Windows service, including automatic startup and description. (scripts/install.bat [1] scripts/uninstall.bat [2]
  • Provided commands.bat with shortcuts for starting, stopping, restarting, and querying the service status. (scripts/commands.bat scripts/commands.batR1-R11)

Dependency Updates:

  • Updated go.mod to add go-svc and update other dependencies to ensure compatibility with the new service management approach. (go.mod go.modL6-R13)

Minor:

…nhance logging

Signed-off-by: Adrián Constante <ad_con.reload@proton.me>
@adcondev adcondev self-assigned this Oct 10, 2025
@adcondev adcondev added the enhancement New feature or request label Oct 10, 2025
Copilot AI review requested due to automatic review settings October 10, 2025 18:09
@adcondev adcondev moved this to In review in POS RED2000 Oct 10, 2025
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR refactors the BasculaServicio project to run as a Windows service using the go-svc library, enabling proper service lifecycle management with start/stop functionality and enhanced logging capabilities.

  • Implements the svc.Service interface with Program struct for proper service lifecycle management
  • Adds Windows service installation/management scripts and logging to PROGRAMDATA directory
  • Sets default configuration to test mode for easier development

Reviewed Changes

Copilot reviewed 7 out of 10 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
cmd/BasculaServicio/main.go Refactored to implement svc.Service interface with Program struct and file-based logging
web/html/index_config.html Updated checkbox to be checked by default for test mode
scripts/install.bat Added Windows service installation script with hardcoded paths
scripts/uninstall.bat Added Windows service removal script
scripts/commands.bat Added service management commands with incorrect batch file syntax
go.mod Updated dependencies to include go-svc library
cmd/BasculaServicio/docs.go Added package documentation

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

adcondev and others added 4 commits October 10, 2025 11:18
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Signed-off-by: Adrián Constante <ad_con.reload@proton.me>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Signed-off-by: Adrián Constante <ad_con.reload@proton.me>
@adcondev adcondev merged commit a570d2b into master Oct 10, 2025
1 check passed
@adcondev adcondev deleted the dev/svc branch October 10, 2025 18:25
@github-project-automation github-project-automation bot moved this from In review to Done in POS RED2000 Oct 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants