.NET Process Boilerplate
Exploring standardized boilerplate for a variety of process types.
Here's a known list of process types:
- Windows Form running as a short-lived client application
- Long-running Windows Service.
- Long-running Task Tray app.
- Short-lived admin task.
- Camunda worker service.
General Process NeedsActions
- Startup Debug
HooksHooking - Hookup Unhandled Exception Handler
- Name the current thread
- Assembly and Dependency Identification
- Load Global App Data (app name, appid, runtimeid, installid, version, etc)
- Memory Logging Setup
- Argument Collection
- OS Verification Check
- Configuration Service
- Locate HCS Instance
- Secrets Service
- Logging Service
- Telemetry Service
- Status Publishing Service
Startup Debug Hooks
Top of Program:main, we include an optional debug spin-wait.
This is triggered by a command-line argument to debug the process.
If activated, the process will wait for a debugger to connect, so early startup activities can be diagnosed.
See this page for implementation details: DotNet Startup Remote Debugging Hook
Secrets Service
- Initial Process Secret - SPIRE-given secret, used to retrieve client token for secrets access.
- Secrets - pulled from central secrets store
Configuration Service
Logging Service
Manages logging for the process:
LoggingPerformsService-logging setup for the process- Sets up the NLog instance (or, whichever is used)
- Retrieves any static config
definingof where to store or ship logs. - Folder Locations - for log files and local configuration
Telemetry Service
publishesPublishes action spans and metrics.metrics to a central collector.
Status Publishing Service
For publishing when a process starts, ends, errors, and periodically while running.
This service is responsible for publishing process metadata, such as:
- App Name
- AppId, RuntimeId, InstallationId
- Exe name
- Exe version and build number
- Start Time
- Machine Host
- Environment
- All dependencies and versions
- Source Repository URL and Rev
- Status: starting, running, shutting down
- Where logs are stored