Hey everyone! Over the past couple of months, I've been wrapping apps and utilities as Windows Services for various projects at work. I've tried tools like WinSW and NSSM, but I often run into bugs or missing features, especially related to log rotation and service management. This experience inspired me to create WinLet, a lightweight and production-focused Windows service wrapper that we now use internally. It's designed to be easy to use while providing great support for log management, environment variables, restart policies, and more. Here are some key features:
- Run any script or executable as a Windows Service
- Comprehensive log management options including rotation and compression
- Configurable auto-restart on service failure
- Small footprint
- Simple TOML configuration
For instance, here's an example configuration:
```toml
[service]
name = "my-web-api"
display_name = "My Web API"
description = "Production web API with monitoring"
[process]
executable = "node"
arguments = "server.js"
working_directory = "C:\Apps\MyWebAPI"
shutdown_timeout_seconds = 45
[process.environment]
NODE_ENV = "production"
PORT = "3000"
DATABASE_URL = "postgresql://db-server/myapi"
[logging]
level = "Information"
log_path = "C:\Logs\MyWebAPI"
mode = "RollBySizeTime"
size_threshold_kb = 25600
time_pattern = "yyyyMMdd"
auto_roll_at_time = "02:00:00"
keep_files = 14
zip_older_than_days = 3
separate_error_log = true
[restart]
policy = "OnFailure"
delay_seconds = 10
max_attempts = 5
window_seconds = 600
[service_account]
username = "DOMAIN\WebAPIService"
allow_service_logon = true
prompt = "Console"
```
You can install and start it using:
```
WinLet.exe install --config my-web-api.toml
WinLet.exe start --name my-web-api
```
Looking ahead, I have plans to add features like Prometheus metrics, a PowerShell module, hot-config reloads, service dependency graphs, and a web dashboard for management. I'd love to hear from anyone who manages or uses Windows services! Please share any suggestions or feedback you have, and I hope others find this tool useful too. Check out the GitHub link for more details: ptfpinho23/WinLet: A modern Windows service runner that doesn't suck.
2 Answers
This looks super useful! I'm definitely going to give it a try. Thanks for sharing!
Do you have any plans to include crash dump generation for service failures? That would really help with debugging.
Actually, someone on my team mentioned that too! It's on my to-do list. Thanks for the suggestion!