From dca1d8b52c778f4189a08060736c80987a854966 Mon Sep 17 00:00:00 2001 From: GottemHams Date: Sun, 3 Jul 2022 15:56:49 +0200 Subject: [PATCH 1/3] Added session type to macOS service plist --- Library/Homebrew/service.rb | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Library/Homebrew/service.rb b/Library/Homebrew/service.rb index 6ba9919862..25b57cd319 100644 --- a/Library/Homebrew/service.rb +++ b/Library/Homebrew/service.rb @@ -376,6 +376,13 @@ module Homebrew 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] = ["Aqua", "Background", "LoginWindow", "StandardIO", "System"] + base.to_plist end From dec8577d18fd76a7d850aa34a29ad19e1f1cd2de Mon Sep 17 00:00:00 2001 From: GottemHams Date: Sun, 3 Jul 2022 16:24:05 +0200 Subject: [PATCH 2/3] Comply with style checks --- Library/Homebrew/service.rb | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/Library/Homebrew/service.rb b/Library/Homebrew/service.rb index 25b57cd319..f40cff066f 100644 --- a/Library/Homebrew/service.rb +++ b/Library/Homebrew/service.rb @@ -376,12 +376,13 @@ module Homebrew 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] = ["Aqua", "Background", "LoginWindow", "StandardIO", "System"] + # 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 From 956b457f774041e0879a18ae6ffaa67b6da3842d Mon Sep 17 00:00:00 2001 From: GottemHams Date: Sun, 3 Jul 2022 16:25:19 +0200 Subject: [PATCH 3/3] Updated expected plist strings to pass the tests --- Library/Homebrew/test/service_spec.rb | 64 +++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) diff --git a/Library/Homebrew/test/service_spec.rb b/Library/Homebrew/test/service_spec.rb index f54d8d8be6..e35f0f4cb9 100644 --- a/Library/Homebrew/test/service_spec.rb +++ b/Library/Homebrew/test/service_spec.rb @@ -180,6 +180,14 @@ describe Homebrew::Service do \t \tLegacyTimers \t + \tLimitLoadToSessionType + \t + \t\tAqua + \t\tBackground + \t\tLoginWindow + \t\tStandardIO + \t\tSystem + \t \tProcessType \tInteractive \tProgramArguments @@ -221,6 +229,14 @@ describe Homebrew::Service do \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 @@ describe Homebrew::Service do \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 @@ describe Homebrew::Service do \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 @@ describe Homebrew::Service do \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 @@ describe Homebrew::Service do \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 @@ describe Homebrew::Service do \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 @@ describe Homebrew::Service do \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