반응형
Capistrano v3의 서버에서 쉘 명령을 실행하는 방법은 무엇입니까?
저는 Capistrano를 처음 접했고 Capistrano의 DSL을 사용하여 서버에서 셸 명령 ( 'run', 'execute'등)을 실행하려고 시도했지만 더 이상 사용되지 않는 것으로 보입니다. 기능적으로 동등한 것을 검색하고 검색 한 후에도 여전히 길을 잃었습니다.
현재 코드 :
desc 'Do something'
task :do_something
execute 'echo sometext'
end
산출:
cap aborted!
undefined method `execute' for main:Object
/Users/Justin/Dropbox/xxxx/xxxx/xxxx/Capfile:45:in `block (2 levels) in <top (required)>'
/Users/Justin/.rvm/gems/ruby-2.0.0-p247/bundler/gems/capistrano-2dc1627838f9/lib/capistrano/application.rb:12:in `run'
/Users/Justin/.rvm/gems/ruby-2.0.0-p247/bundler/gems/capistrano-2dc1627838f9/bin/cap:3:in `<top (required)>'
/Users/Justin/.rvm/gems/ruby-2.0.0-p247/bin/cap:23:in `load'
/Users/Justin/.rvm/gems/ruby-2.0.0-p247/bin/cap:23:in `<main>'
/Users/Justin/.rvm/gems/ruby-2.0.0-p247/bin/ruby_noexec_wrapper:14:in `eval'
/Users/Justin/.rvm/gems/ruby-2.0.0-p247/bin/ruby_noexec_wrapper:14:in `<main>'
Tasks: TOP => deploy:do_something
Capistrano v3에서는 on
호스트 이름 목록을 호출하여 코드를 실행할 위치를 지정해야합니다 . 예 :
task :execute_on_server do
on "root@example.com" do
execute "some_command"
end
end
역할이 설정되어 있으면이 roles
방법을 편리하게 사용할 수 있습니다 .
role :mailserver, "root@mail.example.com"
task :check_mail do
on roles(:mailserver) do
execute "some_command"
end
end
여기에 v3 문서가 있습니다 : http://www.capistranorb.com/
참고 URL : https://stackoverflow.com/questions/18838930/how-to-run-shell-commands-on-server-in-capistrano-v3
반응형
'developer tip' 카테고리의 다른 글
MongoDB mongorestore 및 레코드가있는 기존 컬렉션 (0) | 2020.10.27 |
---|---|
matplotlib에서 imshow에 의해 표시된 이미지 반전 (0) | 2020.10.27 |
인증 자격 증명 제거 — django, elastic beanstalk, oauth (0) | 2020.10.27 |
문자열을 사용하여 동적으로 메서드를 호출하는 Objective C (0) | 2020.10.27 |
Glimpse를 프로덕션 사이트에 배포해야합니까? (0) | 2020.10.27 |