diff --git a/Library/Homebrew/service.rb b/Library/Homebrew/service.rb
index 6ba9919862d81..f40cff066fb0b 100644
--- a/Library/Homebrew/service.rb
+++ b/Library/Homebrew/service.rb
@@ -376,6 +376,14 @@ def to_plist
base[:StartCalendarInterval] = @cron.reject { |_, value| value == "*" }
end
+ # Adding all session types has as the primary effect that if you initialise it through e.g. a Background session
+ # and you later "physically" sign in to the owning account (Aqua session), things shouldn't flip out.
+ # Also, we're not checking @process_type here because that is used to indicate process priority and not
+ # necessarily if it should run in a specific session type. Like database services could run with ProcessType
+ # Interactive so they have no resource limitations enforced upon them, but they aren't really interactive in the
+ # general sense.
+ base[:LimitLoadToSessionType] = %w[Aqua Background LoginWindow StandardIO System]
+
base.to_plist
end
diff --git a/Library/Homebrew/test/service_spec.rb b/Library/Homebrew/test/service_spec.rb
index f54d8d8be6cb5..e35f0f4cb947a 100644
--- a/Library/Homebrew/test/service_spec.rb
+++ b/Library/Homebrew/test/service_spec.rb
@@ -180,6 +180,14 @@
\t
\tLegacyTimers
\t
+ \tLimitLoadToSessionType
+ \t
+ \t\tAqua
+ \t\tBackground
+ \t\tLoginWindow
+ \t\tStandardIO
+ \t\tSystem
+ \t
\tProcessType
\tInteractive
\tProgramArguments
@@ -221,6 +229,14 @@
\tLabel
\thomebrew.mxcl.formula_name
+ \tLimitLoadToSessionType
+ \t
+ \t\tAqua
+ \t\tBackground
+ \t\tLoginWindow
+ \t\tStandardIO
+ \t\tSystem
+ \t
\tProgramArguments
\t
\t\t#{HOMEBREW_PREFIX}/opt/formula_name/bin/beanstalkd
@@ -262,6 +278,14 @@
\tLabel
\thomebrew.mxcl.formula_name
+ \tLimitLoadToSessionType
+ \t
+ \t\tAqua
+ \t\tBackground
+ \t\tLoginWindow
+ \t\tStandardIO
+ \t\tSystem
+ \t
\tProgramArguments
\t
\t\t#{HOMEBREW_PREFIX}/opt/formula_name/bin/beanstalkd
@@ -289,6 +313,14 @@
\tLabel
\thomebrew.mxcl.formula_name
+ \tLimitLoadToSessionType
+ \t
+ \t\tAqua
+ \t\tBackground
+ \t\tLoginWindow
+ \t\tStandardIO
+ \t\tSystem
+ \t
\tProgramArguments
\t
\t\t#{HOMEBREW_PREFIX}/opt/formula_name/bin/beanstalkd
@@ -318,6 +350,14 @@
\tLabel
\thomebrew.mxcl.formula_name
+ \tLimitLoadToSessionType
+ \t
+ \t\tAqua
+ \t\tBackground
+ \t\tLoginWindow
+ \t\tStandardIO
+ \t\tSystem
+ \t
\tProgramArguments
\t
\t\t#{HOMEBREW_PREFIX}/opt/formula_name/bin/beanstalkd
@@ -356,6 +396,14 @@
\t
\tLabel
\thomebrew.mxcl.formula_name
+ \tLimitLoadToSessionType
+ \t
+ \t\tAqua
+ \t\tBackground
+ \t\tLoginWindow
+ \t\tStandardIO
+ \t\tSystem
+ \t
\tProgramArguments
\t
\t\t#{HOMEBREW_PREFIX}/opt/formula_name/bin/beanstalkd
@@ -387,6 +435,14 @@
\t
\tLabel
\thomebrew.mxcl.formula_name
+ \tLimitLoadToSessionType
+ \t
+ \t\tAqua
+ \t\tBackground
+ \t\tLoginWindow
+ \t\tStandardIO
+ \t\tSystem
+ \t
\tProgramArguments
\t
\t\t#{HOMEBREW_PREFIX}/opt/formula_name/bin/beanstalkd
@@ -418,6 +474,14 @@
\t
\tLabel
\thomebrew.mxcl.formula_name
+ \tLimitLoadToSessionType
+ \t
+ \t\tAqua
+ \t\tBackground
+ \t\tLoginWindow
+ \t\tStandardIO
+ \t\tSystem
+ \t
\tProgramArguments
\t
\t\t#{HOMEBREW_PREFIX}/opt/formula_name/bin/beanstalkd