gpt4 book ai didi

ruby-on-rails-4 - Capistrano3 中的 sudo 命令不显示密码提示

转载 作者:太空宇宙 更新时间:2023-11-03 17:17:44 24 4
gpt4 key购买 nike

我正在运行 cap production deploy:setup_config

我得到以下输出:

DEBUG[659d52b0] Running /usr/bin/env [ ! -d /home/deployer/.rbenv/versions/2.1.2 ] on xxx.xxx.xxx.xxx
DEBUG[659d52b0] Command: [ ! -d /home/deployer/.rbenv/versions/2.1.2 ]
DEBUG[659d52b0] Finished in 2.413 seconds with exit status 1 (failed).
DEBUG[2ea020b0] Running /usr/bin/env [ -f /etc/nginx/sites-enabled/default ] on xxx.xxx.xxx.xxx
DEBUG[2ea020b0] Command: [ -f /etc/nginx/sites-enabled/default ]
DEBUG[2ea020b0] Finished in 0.507 seconds with exit status 1 (failed).
No default Nginx Virtualhost to remove
INFO[e0a045fc] Running /usr/bin/env mkdir -p /home/deployer/apps/managewise_production/shared/config on xxx.xxx.xxx.xxx
DEBUG[e0a045fc] Command: ( RBENV_ROOT=/home/deployer/.rbenv RBENV_VERSION=2.1.2 /usr/bin/env mkdir -p /home/deployer/apps/managewise_production/shared/config )
INFO[e0a045fc] Finished in 0.405 seconds with exit status 0 (successful).
DEBUGUploading /home/deployer/apps/managewise_production/shared/config/nginx.conf 0.0%
INFOUploading /home/deployer/apps/managewise_production/shared/config/nginx.conf 100.0%
INFOcopying: #<StringIO:0x007fad45824cc8> to: /home/deployer/apps/managewise_production/shared/config/nginx.conf
DEBUGUploading /home/deployer/apps/managewise_production/shared/config/database.example.yml 0.0%
INFOUploading /home/deployer/apps/managewise_production/shared/config/database.example.yml 100.0%
INFOcopying: #<StringIO:0x007fad448839e0> to: /home/deployer/apps/managewise_production/shared/config/database.example.yml
DEBUGUploading /home/deployer/apps/managewise_production/shared/config/log_rotation 0.0%
INFOUploading /home/deployer/apps/managewise_production/shared/config/log_rotation 100.0%
INFOcopying: #<StringIO:0x007fad4413b2f0> to: /home/deployer/apps/managewise_production/shared/config/log_rotation
DEBUGUploading /home/deployer/apps/managewise_production/shared/config/monit 0.0%
INFOUploading /home/deployer/apps/managewise_production/shared/config/monit 100.0%
INFOcopying: #<StringIO:0x007fad46816898> to: /home/deployer/apps/managewise_production/shared/config/monit
DEBUGUploading /home/deployer/apps/managewise_production/shared/config/unicorn.rb 0.0%
INFOUploading /home/deployer/apps/managewise_production/shared/config/unicorn.rb 100.0%
INFOcopying: #<StringIO:0x007fad46ab7a20> to: /home/deployer/apps/managewise_production/shared/config/unicorn.rb
DEBUGUploading /home/deployer/apps/managewise_production/shared/config/unicorn_init.sh 0.0%
INFOUploading /home/deployer/apps/managewise_production/shared/config/unicorn_init.sh 100.0%
INFOcopying: #<StringIO:0x007fad46a4f7e0> to: /home/deployer/apps/managewise_production/shared/config/unicorn_init.sh
INFO[a1c87854] Running /usr/bin/env chmod +x /home/deployer/apps/managewise_production/shared/config/unicorn_init.sh on xxx.xxx.xxx.xxx
DEBUG[a1c87854] Command: ( RBENV_ROOT=/home/deployer/.rbenv RBENV_VERSION=2.1.2 /usr/bin/env chmod +x /home/deployer/apps/managewise_production/shared/config/unicorn_init.sh )
INFO[a1c87854] Finished in 0.483 seconds with exit status 0 (successful).
INFO[30551413] Running /usr/bin/env whoami && echo ${PATH} on xxx.xxx.xxx.xxx
DEBUG[30551413] Command: whoami && echo ${PATH}
INFO[30551413] Finished in 0.552 seconds with exit status 0 (successful).
DEBUG[30551413] deployer
DEBUG[30551413] /home/deployer/.rbenv/shims:/home/deployer/.rbenv/bin:/usr/local/bin:/bin:/usr/bin:/home/deployer/bin
INFO[30551413] Finished in 0.552 seconds with exit status 0 (successful).
INFO[60b61747] Running /usr/bin/env sudo ln -nfs /home/deployer/apps/managewise_production/shared/config/nginx.conf /etc/nginx/sites-enabled/ on xxx.xxx.xxx.xxx
DEBUG[60b61747] Command: ( RBENV_ROOT=/home/deployer/.rbenv RBENV_VERSION=2.1.2 /usr/bin/env sudo ln -nfs /home/deployer/apps/managewise_production/shared/config/nginx.conf /etc/nginx/sites-enabled/ )
DEBUG[60b61747] [sudo] password for deployer:

现在当我输入密码时。它显示密码,而且它甚至不起作用。任务如下:lib/capistano/tasks/setup_config.cap

namespace :deploy do
task :setup_config do
on roles(:app) do
# make the config dir
execute :mkdir, "-p #{shared_path}/config"
full_app_name = fetch(:full_app_name)

# config files to be uploaded to shared/config, see the
# definition of smart_template for details of operation.
# Essentially looks for #{filename}.erb in deploy/#{full_app_name}/
# and if it isn't there, falls back to deploy/#{shared}. Generally
# everything should be in deploy/shared with params which differ
# set in the stage files
config_files = fetch(:config_files)
config_files.each do |file|
smart_template file
end

# which of the above files should be marked as executable
executable_files = fetch(:executable_config_files)
executable_files.each do |file|
execute :chmod, "+x #{shared_path}/config/#{file}"
end

# symlink stuff which should be... symlinked
symlinks = fetch(:symlinks)

symlinks.each do |symlink|
execute "whoami && echo ${PATH}"
sudo "ln -nfs #{shared_path}/config/#{symlink[:source]} # sub_strings(symlink[:link])}"
end
end
end
end

在 deploy.rb 中,我有以下关于 ssh 的内容:

set :pty, true
set :ssh_options, { forward_agent: true, :keys => %w(/home/SMD/.ssh/id_rsa)}
set :use_sudo, false
set :default_shell, '/bin/bash --login'

我不知道是什么问题。我也担心失败的代码。 ==>

DEBUG[659d52b0] Command: [ ! -d /home/deployer/.rbenv/versions/2.1.2 ]
DEBUG[659d52b0] Finished in 2.413 seconds with exit status 1 (failed).

提前致谢。

最佳答案

尝试将类似这样的内容添加到您的 deploy.rb 文件(或相应的部署环境文件)

set :password, ask('Server password', nil)
server 'xxx.xxx.xx.xx', user: 'root', port: 22, password: fetch(:password), roles: %w{web app db}, primary: true

关于ruby-on-rails-4 - Capistrano3 中的 sudo 命令不显示密码提示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25242012/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com