Skip to content

Make systemd unit configurable and fix :system-mode defaults#6

Open
floriancrusius wants to merge 2 commits into
codeur:mainfrom
floriancrusius:feature/configurable-systemd-unit
Open

Make systemd unit configurable and fix :system-mode defaults#6
floriancrusius wants to merge 2 commits into
codeur:mainfrom
floriancrusius:feature/configurable-systemd-unit

Conversation

@floriancrusius

Copy link
Copy Markdown

Summary

  • Configurable env vars in the systemd unit — adds :solid_queue_service_unit_env_files and :solid_queue_service_unit_env_vars (inspired by capistrano-sidekiq). Both fall back to shared :service_unit_env_files / :service_unit_env_vars so multi-plugin setups can share one source.
  • Configurable command:solid_queue_command (default "rake solid_queue:start") so SolidQueue >= 0.4 setups can switch to "bin/jobs" without templating.
  • Fix [Install] WantedBy= — now multi-user.target in :system mode (previously always default.target, which prevented boot activation of system units).
  • Fix :system mode running as root — now renders User=<solid_queue_user> (defaults to :run_as, then Capistrano's :user).
  • Breaking: Capistrano's default_env is no longer auto-rendered into the unit; MALLOC_ARENA_MAX=2 is no longer hardcoded. Pass what you need explicitly via the new hooks. RAILS_ENV is still derived from the current stage.

Test plan

  • bundle exec cap <stage> solid_queue:generate and inspect the generated solid_queue.service — verify Environment=, EnvironmentFile=, ExecStart=, User=, WantedBy= look correct in both :user and :system modes.
  • bundle exec cap <stage> solid_queue:install on a staging host, systemctl --user status <unit> (or sudo systemctl status … for :system) — service comes up.
  • Set :solid_queue_service_unit_env_vars, ["FOO=bar"] and confirm it lands in the rendered unit.
  • Set :solid_queue_command, "bin/jobs" on a SolidQueue-0.4+ app and confirm the process starts.

- 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.

Copilot AI left a comment

Copy link
Copy Markdown

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 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_command to control what runs after bundle exec (defaulting to rake solid_queue:start).
  • Adjust :system mode rendering (set User= and use WantedBy=multi-user.target) and document the breaking removal of rendering Capistrano default_env into 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.

Comment thread lib/capistrano/solid_queue.rb
Comment thread README.md Outdated
Comment thread README.md Outdated
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants