简体   繁体   English

用Capistrano激活Virtualenv包装器

[英]Activate Virtualenv Wrapper with Capistrano

I am trying to deploy a Django project with Capistrano. 我正在尝试使用Capistrano部署Django项目。 Capistrano deploys the code to my server and finishes deploy steps. Capistrano将代码部署到我的服务器并完成部署步骤。

But when I try add a custom task like this... 但是当我尝试添加这样的自定义任务时...

task :collect_static do
  on roles(:app) do |host|
    execute "cd #{release_path}/myproject"
    execute "workon myproject"
    execute "./manage.py collectstatic"
  end
end

after "deploy:updated", "collect_static"

It throws the following error... 它引发以下错误...

02 bash: workon: command not found

After the deploy, if I SSH manually onto server and run workon command it works fine(same user). 部署后,如果我手动SSH到服务器上并运行workon命令,它可以正常运行(同一用户)。 Just Capistrano doesn't recognise it? 只是Capistrano无法识别?

workon is not a program but a shell function from virtualenvwrapper . workon不是程序,而是virtualenvwrapper的shell函数。 For bash to find it you have to source virtualenvwrapper.sh in the shell. 为了使bash能够找到它,您必须在shell中获取virtualenvwrapper.sh

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM