Add process_type to service DSL
This enables mpd to be run with the "Interactive" value, which avoids
performance issues such as skipping when playing music. See this PR,
where this was done previously:
https://github.com/Homebrew/homebrew-core/pull/19410
The ProcessType plist key was lost in the conversion to the service DSL:
483ad1fdfa
This commit is contained in:
parent
40a7a01196
commit
698f4a8f69
@ -13,6 +13,11 @@ module Homebrew
|
|||||||
RUN_TYPE_INTERVAL = "interval"
|
RUN_TYPE_INTERVAL = "interval"
|
||||||
RUN_TYPE_CRON = "cron"
|
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 }
|
# sig { params(formula: Formula).void }
|
||||||
def initialize(formula, &block)
|
def initialize(formula, &block)
|
||||||
@formula = formula
|
@formula = formula
|
||||||
@ -119,6 +124,22 @@ module Homebrew
|
|||||||
end
|
end
|
||||||
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)) }
|
sig { params(type: T.nilable(T.any(String, Symbol))).returns(T.nilable(String)) }
|
||||||
def run_type(type = nil)
|
def run_type(type = nil)
|
||||||
case T.unsafe(type)
|
case T.unsafe(type)
|
||||||
@ -193,6 +214,7 @@ module Homebrew
|
|||||||
base[:KeepAlive] = @keep_alive if @keep_alive == true
|
base[:KeepAlive] = @keep_alive if @keep_alive == true
|
||||||
base[:LegacyTimers] = @macos_legacy_timers if @macos_legacy_timers == true
|
base[:LegacyTimers] = @macos_legacy_timers if @macos_legacy_timers == true
|
||||||
base[:TimeOut] = @restart_delay if @restart_delay.present?
|
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[:WorkingDirectory] = @working_dir if @working_dir.present?
|
||||||
base[:RootDirectory] = @root_dir if @root_dir.present?
|
base[:RootDirectory] = @root_dir if @root_dir.present?
|
||||||
base[:StandardInPath] = @input_path if @input_path.present?
|
base[:StandardInPath] = @input_path if @input_path.present?
|
||||||
|
|||||||
@ -76,6 +76,7 @@ describe Homebrew::Service do
|
|||||||
root_dir var
|
root_dir var
|
||||||
working_dir var
|
working_dir var
|
||||||
keep_alive true
|
keep_alive true
|
||||||
|
process_type "interactive"
|
||||||
restart_delay 30
|
restart_delay 30
|
||||||
macos_legacy_timers true
|
macos_legacy_timers true
|
||||||
end
|
end
|
||||||
@ -101,6 +102,8 @@ describe Homebrew::Service do
|
|||||||
\t<string>homebrew.mxcl.formula_name</string>
|
\t<string>homebrew.mxcl.formula_name</string>
|
||||||
\t<key>LegacyTimers</key>
|
\t<key>LegacyTimers</key>
|
||||||
\t<true/>
|
\t<true/>
|
||||||
|
\t<key>ProcessType</key>
|
||||||
|
\t<string>Interactive</string>
|
||||||
\t<key>ProgramArguments</key>
|
\t<key>ProgramArguments</key>
|
||||||
\t<array>
|
\t<array>
|
||||||
\t\t<string>#{HOMEBREW_PREFIX}/opt/formula_name/bin/beanstalkd</string>
|
\t\t<string>#{HOMEBREW_PREFIX}/opt/formula_name/bin/beanstalkd</string>
|
||||||
@ -165,6 +168,7 @@ describe Homebrew::Service do
|
|||||||
root_dir var
|
root_dir var
|
||||||
working_dir var
|
working_dir var
|
||||||
keep_alive true
|
keep_alive true
|
||||||
|
process_type "interactive"
|
||||||
restart_delay 30
|
restart_delay 30
|
||||||
macos_legacy_timers true
|
macos_legacy_timers true
|
||||||
end
|
end
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user