[Unit]
Description=Account Variant Backend (.NET)
After=network.target
Description → Friendly name/short description for the service.
After=network.target → Ensures the service only starts once networking is up.
⚠️ Note: If your app requires a working network connection (e.g., DB or APIs), sometimes you’ll see After=network-online.target with Wants=network-online.target instead, since network.target only means “basic networking is available,” not necessarily connected.
[Service]
WorkingDirectory=/home/cloud/AccountVariantBackendLive
ExecStart=/usr/bin/dotnet /home/cloud/AccountVariantBackendLive/AccountVariantBackendLive.dll
Restart=always
RestartSec=10
KillSignal=SIGINT
SyslogIdentifier=accountvariant-backend
User=cloud
Environment=ASPNETCORE_ENVIRONMENT=Production
Environment=DOTNET_PRINT_TELEMETRY_MESSAGE=false
WorkingDirectory → Sets the folder where the app runs (cd into it before launching).
ExecStart → The exact command that systemd runs to launch your .NET app.
Restart=always → Ensures the service restarts after a crash/kill.
RestartSec=10 → Adds a 10s buffer before restart (avoids rapid crash loops).
KillSignal=SIGINT → Sends Ctrl+C style signal, so the app shuts down gracefully instead of being killed instantly.
SyslogIdentifier → Makes logs easy to filter:
journalctl -u accountvariant-backend
User=cloud → Runs app as non-root user cloud → security best practice.
Environment variables:
ASPNETCORE_ENVIRONMENT=Production → Runs app in optimized, secure mode.DOTNET_PRINT_TELEMETRY_MESSAGE=false → Suppresses .NET runtime startup telemetry messages in logs.[Install]
WantedBy=multi-user.target