-
-
Notifications
You must be signed in to change notification settings - Fork 10.9k
Add Nice option to service #21088
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Nice option to service #21088
Conversation
- Add nice method to Service class with validation (-20 to 19) - Automatically set requires_root for negative nice values - Add Nice support to plist (macOS) and systemd unit (Linux) generation - Add nice to to_hash and from_hash for API serialization - Add comprehensive tests for nice functionality - Update documentation with nice option
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adds support for the nice option to Homebrew services, allowing users to control the scheduling priority of services on both macOS and Linux. The nice level ranges from -20 (highest priority) to 19 (lowest priority).
Key changes:
- Added
nicemethod with validation and automaticrequires_roothandling for negative values - Extended plist and systemd unit generation to include nice values
- Added comprehensive test coverage for all nice-related functionality
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| docs/Formula-Cookbook.md | Documented the new nice option in the service configuration table |
| Library/Homebrew/service.rb | Implemented the nice method with validation, added nice support to plist/systemd generation, and integrated it with API serialization |
| Library/Homebrew/test/service_spec.rb | Added comprehensive test coverage for nice value validation, requires_root behavior, and output generation |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
Copilot reviewed 3 out of 3 changed files in this pull request and generated no new comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
MikeMcQuaid
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, looks great so far, a few small tweaks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
Copilot reviewed 3 out of 3 changed files in this pull request and generated no new comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
MikeMcQuaid
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, great work here @devnoname120, you rock!
brew lgtm(style, typechecking and tests) with your changes locally?Summary
This PR adds support for the
niceoption in Homebrew services, allowing users to set the scheduling priority (nice level) for services on both macOS and Linux.This PR is a follow to #14936
It aims to fix half of #14931
Changes
nicemethod to Service class with validation (accepts integers from -20 to 19)to_plistmethod for macOS launchd plist generationto_systemd_unitmethod for Linux systemd unit generationnicetoto_hashandfrom_hashmethods for API serializationrequires_rootis set when negative nice values are specified (negative nice values require root privileges)Motivation
Previously, Homebrew services supported Apple plist daemons which had Nice support, but with the switch to their own syntax it became impossible to define a nice value. This PR restores that functionality and extends it to work with both macOS (launchd) and Linux (systemd) service managers.
The nice level ranges from -20 (highest priority) to 19 (lowest priority), and an error is raised if negative nice values are used but
requires_rootis missing.