Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
B
brew
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to JiHu GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
KMSCAKKSCFKA AKFACAMADCAS
brew
Commits
fceaa2bb
Unverified
Commit
fceaa2bb
authored
3 years ago
by
Sean Molenaar
Browse files
Options
Downloads
Patches
Plain Diff
Service: add additional options
parent
23bc81cd
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
Library/Homebrew/service.rb
+55
-0
55 additions, 0 deletions
Library/Homebrew/service.rb
Library/Homebrew/test/service_spec.rb
+19
-0
19 additions, 0 deletions
Library/Homebrew/test/service_spec.rb
with
74 additions
and
0 deletions
Library/Homebrew/service.rb
+
55
−
0
View file @
fceaa2bb
...
...
@@ -47,6 +47,30 @@ module Homebrew
end
end
sig
{
params
(
path:
T
.
nilable
(
T
.
any
(
String
,
Pathname
))).
returns
(
T
.
nilable
(
String
))
}
def
root_dir
(
path
=
nil
)
case
T
.
unsafe
(
path
)
when
nil
@root_dir
when
String
,
Pathname
@root_dir
=
path
.
to_s
else
raise
TypeError
,
"Service#root_dir expects a String"
end
end
sig
{
params
(
path:
T
.
nilable
(
T
.
any
(
String
,
Pathname
))).
returns
(
T
.
nilable
(
String
))
}
def
input_path
(
path
=
nil
)
case
T
.
unsafe
(
path
)
when
nil
@input_path
when
String
,
Pathname
@input_path
=
path
.
to_s
else
raise
TypeError
,
"Service#input_path expects a String"
end
end
sig
{
params
(
path:
T
.
nilable
(
T
.
any
(
String
,
Pathname
))).
returns
(
T
.
nilable
(
String
))
}
def
log_path
(
path
=
nil
)
case
T
.
unsafe
(
path
)
...
...
@@ -83,6 +107,18 @@ module Homebrew
end
end
sig
{
params
(
value:
T
.
nilable
(
Integer
)).
returns
(
T
.
nilable
(
Integer
))
}
def
restart_delay
(
value
=
nil
)
case
T
.
unsafe
(
value
)
when
nil
@restart_delay
when
Integer
@restart_delay
=
value
else
raise
TypeError
,
"Service#restart_delay expects an Integer"
end
end
sig
{
params
(
type:
T
.
nilable
(
T
.
any
(
String
,
Symbol
))).
returns
(
T
.
nilable
(
String
))
}
def
run_type
(
type
=
nil
)
case
T
.
unsafe
(
type
)
...
...
@@ -111,6 +147,18 @@ module Homebrew
end
end
sig
{
params
(
value:
T
.
nilable
(
T
::
Boolean
)).
returns
(
T
.
nilable
(
T
::
Boolean
))
}
def
macos_legacy_timers
(
value
=
nil
)
case
T
.
unsafe
(
value
)
when
nil
@macos_legacy_timers
when
true
,
false
@macos_legacy_timers
=
value
else
raise
TypeError
,
"Service#macos_legacy_timers expects a Boolean"
end
end
delegate
[
:bin
,
:etc
,
:libexec
,
:opt_bin
,
:opt_libexec
,
:opt_pkgshare
,
:opt_prefix
,
:opt_sbin
,
:var
]
=>
:@formula
sig
{
returns
(
String
)
}
...
...
@@ -135,7 +183,11 @@ 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
[
:WorkingDirectory
]
=
@working_dir
if
@working_dir
.
present?
base
[
:RootDirectory
]
=
@root_dir
if
@root_dir
.
present?
base
[
:StandardInPath
]
=
@input_path
if
@input_path
.
present?
base
[
:StandardOutPath
]
=
@log_path
if
@log_path
.
present?
base
[
:StandardErrorPath
]
=
@error_log_path
if
@error_log_path
.
present?
base
[
:EnvironmentVariables
]
=
@environment_variables
unless
@environment_variables
.
empty?
...
...
@@ -158,7 +210,10 @@ module Homebrew
options
=
[]
options
<<
"Restart=always"
if
@keep_alive
==
true
options
<<
"RestartSec=
#{
restart_delay
}
"
if
@restart_delay
.
present?
options
<<
"WorkingDirectory=
#{
@working_dir
}
"
if
@working_dir
.
present?
options
<<
"RootDirectory=
#{
@root_dir
}
"
if
@root_dir
.
present?
options
<<
"StandardInput=file:
#{
@input_path
}
"
if
@input_path
.
present?
options
<<
"StandardOutput=append:
#{
@log_path
}
"
if
@log_path
.
present?
options
<<
"StandardError=append:
#{
@error_log_path
}
"
if
@error_log_path
.
present?
if
@environment_variables
.
present?
...
...
This diff is collapsed.
Click to expand it.
Library/Homebrew/test/service_spec.rb
+
19
−
0
View file @
fceaa2bb
...
...
@@ -40,8 +40,12 @@ describe Homebrew::Service do
environment_variables
PATH
:
std_service_path_env
error_log_path
var
/
"log/beanstalkd.error.log"
log_path
var
/
"log/beanstalkd.log"
input_path
var
/
"in/beanstalkd"
root_dir
var
working_dir
var
keep_alive
true
restart_delay
30
macos_legacy_timers
true
end
plist
=
f
.
service
.
to_plist
...
...
@@ -59,17 +63,25 @@ describe Homebrew::Service do
\t
<true/>
\t
<key>Label</key>
\t
<string>homebrew.mxcl.formula_name</string>
\t
<key>LegacyTimers</key>
\t
<true/>
\t
<key>ProgramArguments</key>
\t
<array>
\t\t
<string>
#{
HOMEBREW_PREFIX
}
/opt/formula_name/bin/beanstalkd</string>
\t\t
<string>test</string>
\t
</array>
\t
<key>RootDirectory</key>
\t
<string>
#{
HOMEBREW_PREFIX
}
/var</string>
\t
<key>RunAtLoad</key>
\t
<true/>
\t
<key>StandardErrorPath</key>
\t
<string>
#{
HOMEBREW_PREFIX
}
/var/log/beanstalkd.error.log</string>
\t
<key>StandardInPath</key>
\t
<string>
#{
HOMEBREW_PREFIX
}
/var/in/beanstalkd</string>
\t
<key>StandardOutPath</key>
\t
<string>
#{
HOMEBREW_PREFIX
}
/var/log/beanstalkd.log</string>
\t
<key>TimeOut</key>
\t
<integer>30</integer>
\t
<key>WorkingDirectory</key>
\t
<string>
#{
HOMEBREW_PREFIX
}
/var</string>
</dict>
...
...
@@ -113,8 +125,12 @@ describe Homebrew::Service do
environment_variables
PATH
:
std_service_path_env
error_log_path
var
/
"log/beanstalkd.error.log"
log_path
var
/
"log/beanstalkd.log"
input_path
var
/
"in/beanstalkd"
root_dir
var
working_dir
var
keep_alive
true
restart_delay
30
macos_legacy_timers
true
end
unit
=
f
.
service
.
to_systemd_unit
...
...
@@ -127,7 +143,10 @@ describe Homebrew::Service do
Type=simple
ExecStart=
#{
HOMEBREW_PREFIX
}
/opt/
#{
name
}
/bin/beanstalkd test
Restart=always
RestartSec=30
WorkingDirectory=
#{
HOMEBREW_PREFIX
}
/var
RootDirectory=
#{
HOMEBREW_PREFIX
}
/var
StandardInput=file:
#{
HOMEBREW_PREFIX
}
/var/in/beanstalkd
StandardOutput=append:
#{
HOMEBREW_PREFIX
}
/var/log/beanstalkd.log
StandardError=append:
#{
HOMEBREW_PREFIX
}
/var/log/beanstalkd.error.log
Environment=
\"
PATH=
#{
std_path
}
\"
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment