diff --git a/Library/Homebrew/service.rb b/Library/Homebrew/service.rb
index 3165d9ea9b..493dcfb42e 100644
--- a/Library/Homebrew/service.rb
+++ b/Library/Homebrew/service.rb
@@ -13,6 +13,11 @@ module Homebrew
RUN_TYPE_INTERVAL = "interval"
RUN_TYPE_CRON = "cron"
+ PROCESS_TYPE_BACKGROUND = "background"
+ PROCESS_TYPE_STANDARD = "standard"
+ PROCESS_TYPE_INTERACTIVE = "interactive"
+ PROCESS_TYPE_ADAPTIVE = "adaptive"
+
# sig { params(formula: Formula).void }
def initialize(formula, &block)
@formula = formula
@@ -119,6 +124,22 @@ module Homebrew
end
end
+ sig { params(type: T.nilable(String)).returns(T.nilable(String)) }
+ def process_type(type = nil)
+ case T.unsafe(type)
+ when nil
+ @process_type
+ when PROCESS_TYPE_BACKGROUND, PROCESS_TYPE_STANDARD, PROCESS_TYPE_INTERACTIVE, PROCESS_TYPE_ADAPTIVE
+ @process_type = type.to_s
+ when String
+ raise TypeError, "Service#process_type allows: "\
+ "'#{PROCESS_TYPE_BACKGROUND}'/'#{PROCESS_TYPE_STANDARD}'/"\
+ "'#{PROCESS_TYPE_INTERACTIVE}'/'#{PROCESS_TYPE_ADAPTIVE}'"
+ else
+ raise TypeError, "Service#process_type expects a String"
+ end
+ end
+
sig { params(type: T.nilable(T.any(String, Symbol))).returns(T.nilable(String)) }
def run_type(type = nil)
case T.unsafe(type)
@@ -193,6 +214,7 @@ module Homebrew
base[:KeepAlive] = @keep_alive if @keep_alive == true
base[:LegacyTimers] = @macos_legacy_timers if @macos_legacy_timers == true
base[:TimeOut] = @restart_delay if @restart_delay.present?
+ base[:ProcessType] = @process_type.capitalize if @process_type.present?
base[:WorkingDirectory] = @working_dir if @working_dir.present?
base[:RootDirectory] = @root_dir if @root_dir.present?
base[:StandardInPath] = @input_path if @input_path.present?
diff --git a/Library/Homebrew/test/service_spec.rb b/Library/Homebrew/test/service_spec.rb
index efa4391798..4c63811914 100644
--- a/Library/Homebrew/test/service_spec.rb
+++ b/Library/Homebrew/test/service_spec.rb
@@ -76,6 +76,7 @@ describe Homebrew::Service do
root_dir var
working_dir var
keep_alive true
+ process_type "interactive"
restart_delay 30
macos_legacy_timers true
end
@@ -101,6 +102,8 @@ describe Homebrew::Service do
\thomebrew.mxcl.formula_name
\tLegacyTimers
\t
+ \tProcessType
+ \tInteractive
\tProgramArguments
\t
\t\t#{HOMEBREW_PREFIX}/opt/formula_name/bin/beanstalkd
@@ -165,6 +168,7 @@ describe Homebrew::Service do
root_dir var
working_dir var
keep_alive true
+ process_type "interactive"
restart_delay 30
macos_legacy_timers true
end