Skip to content

Commit

Permalink
Capistrano rbenv uses bundle instead of bundler (#252)
Browse files Browse the repository at this point in the history
  • Loading branch information
uxxman authored Jun 8, 2020
1 parent bd3cfc3 commit 6ef104f
Showing 1 changed file with 1 addition and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ After=syslog.target network.target
[Service]
Type=simple
WorkingDirectory=<%= File.join(fetch(:deploy_to), 'current') %>
ExecStart=<%= SSHKit.config.command_map[:bundler] %> exec sidekiq -e <%= fetch(:sidekiq_env) %>
ExecStart=<%= SSHKit.config.command_map[:bundle] %> exec sidekiq -e <%= fetch(:sidekiq_env) %>
ExecReload=/bin/kill -TSTP $MAINPID
ExecStop=/bin/kill -TERM $MAINPID
<%="StandardOutput=append:#{fetch(:sidekiq_log)}" if fetch(:sidekiq_log) %>
Expand Down

11 comments on commit 6ef104f

@Paprikas
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi, @uxxman. How do you come up with this?
Here is some details on how this commit breaks deploy #259 (comment)

@uxxman
Copy link
Contributor Author

@uxxman uxxman commented on 6ef104f Aug 13, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Paprikas
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see. So we have to overwrite this var instead.
I guess we should add this to readme.
SSHKit.config.command_map[:bundle] = "#{fetch(:rbenv_path)}/bin/rbenv exec bundler"

@seuros
Copy link
Owner

@seuros seuros commented on 6ef104f Aug 13, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Paprikas : go ahead

@Paprikas
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@seuros @uxxman What about rvm? How systemd config file looks for those who use rvm?
Also I think that the whole line looks wrong now for systemd. (mean whats inside SSHKit.config.command_map[:bundle])

@uxxman
Copy link
Contributor Author

@uxxman uxxman commented on 6ef104f Aug 13, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@seuros @uxxman What about rvm? How systemd config file looks for those who use rvm?
Also I think that the whole line looks wrong now for systemd. (mean whats inside SSHKit.config.command_map[:bundle])

Rvm handles thing similarly
https://github.com/capistrano/rvm/blob/9cfef39cf0022839dca6b5b330dfefeb5fc363e7/lib/capistrano/tasks/rvm.rake#L53

SSHKit.config.command_map is capistrano specific, capistrano runs commands via ssh on a remote server, this command map holds executable path for each command.

RVM => https://github.com/capistrano/rvm/blob/9cfef39cf0022839dca6b5b330dfefeb5fc363e7/lib/capistrano/tasks/rvm.rake#L41

Rbenv => https://github.com/capistrano/rbenv/blob/1fdb93a6dd4a4ab3fb786c995055cf6949daf7a4/lib/capistrano/tasks/rbenv.rake#L23

So if use install git on the server at /use/local/custom/git/bin, SSHKit.config.command_map can map git to this path, so in capistrano tasks you can just write execute :git

@Paprikas
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@uxxman Should we use another var for ruby executable, since executable with ENV vars makes systemd config file incorrect?

@uxxman
Copy link
Contributor Author

@uxxman uxxman commented on 6ef104f Aug 14, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ruby executables and paths are set by their respective capistrano tasks (capistrano-rbenv or capistrano-rvm).

Capistrano-sidekiq is only responsible for the sidekiq executable. The systemd configuration is just a template here, the deployed version has exact absolute values.

@Paprikas
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I mean SSHKit.config.command_map[:bundle] includes ENV vars. So result config will contain
ExecStart=RBENV_ROOT=/usr/local/rbenv RBENV_VERSION=2.7.1 /usr/local/rbenv/bin/rbenv exec bundle exec sidekiq -e production
and that is incorrect format.

@uxxman
Copy link
Contributor Author

@uxxman uxxman commented on 6ef104f Aug 14, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not really, env vars are not printed with SSHKit.config.command_map. This what I get when the systemd ERB template gets compiled,

ExecStart=$HOME/.rbenv/bin/rbenv exec bundle exec sidekiq -e production

@Paprikas
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see that the problem is in my config. Default usage of rbenv_prefix option leads to bad exec. (didn't remove it after switching to systemd)
Thank you. Case closed :D

Please sign in to comment.