Make systemd unit configurable and fix :system-mode defaults#6
Open
floriancrusius wants to merge 2 commits into
Open
Make systemd unit configurable and fix :system-mode defaults#6floriancrusius wants to merge 2 commits into
floriancrusius wants to merge 2 commits into
Conversation
- Add :solid_queue_service_unit_env_files / :solid_queue_service_unit_env_vars for injecting EnvironmentFile= and Environment="KEY=VALUE" lines into the unit (inspired by capistrano-sidekiq). Both fall back to shared :service_unit_env_files / :service_unit_env_vars. - Add :solid_queue_command (default "rake solid_queue:start") so setups on SolidQueue >= 0.4 can switch to "bin/jobs" without templating. - Fix WantedBy: multi-user.target when running in :system mode (previously always default.target, which prevented boot activation of system units). - Fix :system mode running the service implicitly as root — now uses :solid_queue_user (falls back to :run_as, then :user). - Drop implicit rendering of Capistrano's default_env and the hardcoded MALLOC_ARENA_MAX=2; pass anything you need explicitly via the new hooks. RAILS_ENV is still derived from the current stage.
There was a problem hiding this comment.
Pull request overview
This PR enhances the SolidQueue systemd integration by making the generated unit file more configurable (command + environment injection) and by correcting :system-mode unit defaults so services can be enabled at boot and run as a non-root user.
Changes:
- Add configuration for the systemd unit’s environment (
:solid_queue_service_unit_env_files/:solid_queue_service_unit_env_vars) with fallbacks to shared:service_unit_env_*variables. - Add
:solid_queue_commandto control what runs afterbundle exec(defaulting torake solid_queue:start). - Adjust
:systemmode rendering (setUser=and useWantedBy=multi-user.target) and document the breaking removal of rendering Capistranodefault_envinto the unit.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| README.md | Documents new configuration knobs for command, user, and unit environment injection. |
| lib/capistrano/templates/solid_queue.service.erb | Updates the unit template to use configurable env/files, configurable command, and corrected :system defaults (User=, WantedBy=). |
| lib/capistrano/solid_queue.rb | Introduces new default variables for command/user/unit env sources. |
| CHANGELOG.md | Records new configuration features, fixes, and breaking behavior change. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
:solid_queue_service_unit_env_filesand:solid_queue_service_unit_env_vars(inspired bycapistrano-sidekiq). Both fall back to shared:service_unit_env_files/:service_unit_env_varsso multi-plugin setups can share one source.:solid_queue_command(default"rake solid_queue:start") so SolidQueue >= 0.4 setups can switch to"bin/jobs"without templating.[Install] WantedBy=— nowmulti-user.targetin:systemmode (previously alwaysdefault.target, which prevented boot activation of system units).:systemmode running as root — now rendersUser=<solid_queue_user>(defaults to:run_as, then Capistrano's:user).default_envis no longer auto-rendered into the unit;MALLOC_ARENA_MAX=2is no longer hardcoded. Pass what you need explicitly via the new hooks.RAILS_ENVis still derived from the current stage.Test plan
bundle exec cap <stage> solid_queue:generateand inspect the generatedsolid_queue.service— verifyEnvironment=,EnvironmentFile=,ExecStart=,User=,WantedBy=look correct in both:userand:systemmodes.bundle exec cap <stage> solid_queue:installon a staging host,systemctl --user status <unit>(orsudo systemctl status …for:system) — service comes up.:solid_queue_service_unit_env_vars, ["FOO=bar"]and confirm it lands in the rendered unit.:solid_queue_command, "bin/jobs"on a SolidQueue-0.4+ app and confirm the process starts.