Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

- `RAILS_ENV` of the systemd service now comes from `:rails_env`, falling back to `:stage` [#8](https://github.com/codeur/capistrano-solid_queue/issues/8). Run `cap <stage> solid_queue:install` again to update an installed service.
- `solid_queue:quiet` no longer aborts the deploy when `systemctl` fails, as before 0.1.1.
- `default_env` values in the systemd service are expanded by the server shell, as in Capistrano commands, so `RBENV_ROOT=$HOME/.rbenv` set by capistrano-rbenv becomes an absolute path [#1](https://github.com/codeur/capistrano-solid_queue/issues/1). Run `cap <stage> solid_queue:install` again to update an installed service.

## [0.1.2] - 2025-06-12

Expand Down
2 changes: 1 addition & 1 deletion lib/capistrano/templates/solid_queue.service.erb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ After=syslog.target network.target
Type=simple
Environment='RAILS_ENV=<%= fetch(:rails_env, fetch(:stage)) %>'
<% fetch(:default_env).reject{ |k, _| k.to_s == 'path' }.each do |variable, value| -%>
Environment='<%= variable.to_s.upcase %>=<%= value.to_s %>'
Environment='<%= variable.to_s.upcase %>=<%= capture(:printf, "%s", %("#{value.to_s.gsub('"', '\"')}")) %>'
<% end -%>
WorkingDirectory=<%= current_path %>
ExecStart=<%= capture(:echo, SSHKit.config.command_map[:bundle]).strip %> exec rake solid_queue:start
Expand Down
19 changes: 19 additions & 0 deletions test/capistrano/test_service_unit.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,25 @@ def test_rails_env_defaults_to_stage
assert_includes unit, "Environment='RAILS_ENV=preprod'"
end

def test_default_env_is_expanded_by_the_server_shell
unit = generate_unit(stage_config: 'set :default_env, { rbenv_root: "$HOME/.rbenv", rbenv_version: "3.3.0" }')

assert_includes unit, "Environment='RBENV_ROOT=#{Dir.home}/.rbenv'"
assert_includes unit, "Environment='RBENV_VERSION=3.3.0'"
end

def test_default_env_keeps_double_quotes
unit = generate_unit(stage_config: %(set :default_env, { greeting: 'say "hi"' }))

assert_includes unit, %(Environment='GREETING=say "hi"')
end

def test_default_env_keeps_values_starting_with_dashes
unit = generate_unit(stage_config: 'set :default_env, { ruby_configure_opts: "--with-jemalloc=/usr/include/jemalloc --enable-yjit" }')

assert_includes unit, "Environment='RUBY_CONFIGURE_OPTS=--with-jemalloc=/usr/include/jemalloc --enable-yjit'"
end

private

def generate_unit(stage_config: "")
Expand Down
Loading