From 16e341d9b5feb436a9e4ac47bec671c864fbb15d Mon Sep 17 00:00:00 2001 From: Josh Martin <101206194+jbmartino@users.noreply.github.com> Date: Wed, 22 Jul 2026 00:05:52 -0400 Subject: [PATCH] fix: key singleton mutex on config folder (#2946) * fix: key singleton mutex on config folder * update changelog --------- Co-authored-by: Jason Dove <1695733+jasongdove@users.noreply.github.com> --- CHANGELOG.md | 1 + ErsatzTV/Program.cs | 9 ++++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 07232925e..ab7794363 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). - Playlists ignored this setting in earlier builds - Always randomize start points for all collections the first time they are used - Previously, only collections scheduled during the first day of a playout build had their start points randomized +- Allow multiple ETV instances when multiple config folders are used ## [26.6.0] - 2026-07-09 ### Added diff --git a/ErsatzTV/Program.cs b/ErsatzTV/Program.cs index 2bfcae1f0..8267492b5 100644 --- a/ErsatzTV/Program.cs +++ b/ErsatzTV/Program.cs @@ -1,6 +1,8 @@ using System.Diagnostics; using System.Globalization; using System.Runtime.InteropServices; +using System.Security.Cryptography; +using System.Text; using Destructurama; using ErsatzTV.Core; using ErsatzTV.Services.Validators; @@ -47,9 +49,14 @@ public class Program public static async Task Main(string[] args) { + // Keyed on the config folder, not a constant, so an instance running against an + // isolated ETV_CONFIG_FOLDER (a staging copy) can coexist with the primary one. + string singletonId = Convert.ToHexString( + SHA256.HashData(Encoding.UTF8.GetBytes(FileSystemLayout.AppDataFolder)))[..16]; + using var _ = new Mutex( true, - "Global\\ErsatzTV.Singleton.74360cd8985c4d1fb6bc9e81887206fe", + $"Global\\ErsatzTV.Singleton.{singletonId}", out bool createdNew); if (!createdNew) {