1
0
Fork 0
mirror of https://gitlab.com/ydkn/capistrano-rails-console.git synced 2023-02-13 20:54:14 -05:00

allow to set shell (refs #31)

This commit is contained in:
Florian Schwab 2018-02-03 23:12:13 +01:00
parent 99743c0ac3
commit a14cc3660c
4 changed files with 15 additions and 7 deletions

View file

@ -2,7 +2,8 @@
## Unreleased ## Unreleased
### Feature ### Feature
- Allow to set capistrano role to select server for remote console #33 - allow to set capistrano role to select server for remote console (#33)
- allow to set shell used on server (#31)
## 2.2.1 (2017-09-04) ## 2.2.1 (2017-09-04)
### Feature ### Feature

View file

@ -72,6 +72,12 @@ set :console_user, nil # explicitly disable switching user through sudo
set :console_role, :app # start remote console on primary server for this role set :console_role, :app # start remote console on primary server for this role
``` ```
### Shell
```ruby
set :console_shell, '/bin/bash' # select shell to be used on server in case you experience problems (see #31)
```
## Contributing ## Contributing

View file

@ -19,7 +19,7 @@ Gem::Specification.new do |spec|
spec.require_paths = ['lib'] spec.require_paths = ['lib']
spec.add_dependency 'capistrano', '>= 3.5.0', '< 4.0.0' spec.add_dependency 'capistrano', '>= 3.5.0', '< 4.0.0'
spec.add_dependency 'sshkit-interactive', '~> 0.2.0' spec.add_dependency 'sshkit-interactive', '~> 0.3.0'
spec.add_development_dependency 'bundler' spec.add_development_dependency 'bundler'
spec.add_development_dependency 'rake' spec.add_development_dependency 'rake'

View file

@ -7,9 +7,10 @@ namespace :load do
end end
# Default values # Default values
set :console_env, -> { fetch(:rails_env, fetch(:stage, 'production')) } set :console_env, -> { fetch(:rails_env, fetch(:stage, 'production')) }
set :console_user, -> { fetch(:app_user, nil) } set :console_user, -> { fetch(:app_user, nil) }
set :console_role, :app set :console_role, :app
set :console_shell, nil
end end
end end
@ -19,7 +20,7 @@ namespace :rails do
args = [] args = []
args << '--sandbox' if ENV.key?('sandbox') || ENV.key?('s') args << '--sandbox' if ENV.key?('sandbox') || ENV.key?('s')
run_interactively primary(fetch(:console_role)) do run_interactively primary(fetch(:console_role)), shell: fetch(:console_shell) do
within current_path do within current_path do
as user: fetch(:console_user) do as user: fetch(:console_user) do
execute(:rails, :console, fetch(:console_env), *args) execute(:rails, :console, fetch(:console_env), *args)
@ -30,7 +31,7 @@ namespace :rails do
desc 'Interact with a remote rails dbconsole' desc 'Interact with a remote rails dbconsole'
task :dbconsole do task :dbconsole do
run_interactively primary(fetch(:console_role)) do run_interactively primary(fetch(:console_role)), shell: fetch(:console_shell) do
within current_path do within current_path do
as user: fetch(:console_user) do as user: fetch(:console_user) do
execute(:rails, :dbconsole, '-p', '-e', fetch(:console_env)) execute(:rails, :dbconsole, '-p', '-e', fetch(:console_env))