2

我正在运行结构(Django 部署到 apache),一切似乎都运行良好,直到我完成安装站点的任务:

def install_site():
    "Add the virtualhost file to apache"
    require('release', provided_by=[deploy, setup])
    sudo('cd %(path)/releases/%(release)/%(release); cp %(project_name)/%(virtualhost_path)/%(project_domain) /etc/apache2/sites-available/%(project_domain)s')
    sudo('cd /etc/apache2/sites-available; a2ensite %(project_domain)') 

我不断收到此错误:

[173.203.124.16] sudo: cd %(path)/releases/%(release)/%(release);
[173.203.124.16] err: /bin/bash: -c: line 0: syntax error near unexpected token
`('
[173.203.124.16] err: /bin/bash: -c: line 0: `cd %(path)/releases/%(release)/%(r
elease);'

Warning: sudo() encountered an error (return code 2) while executing 'cd %(path)
/releases/%(release)/%(release);'

我一遍又一遍地浏览了 fabfile.py ,我看不出为什么会出现错误……有什么想法吗?

4

3 回答 3

4
def install_site():
    "Add the virtualhost file to apache"
    require('release', provided_by=[deploy, setup])

    with cd('%(path)s/releases/%(release)s/%(release)s' % env):
        sudo('cp %(project_name)s/%(virtualhost_path)s/%(project_domain)s '
                 '/etc/apache2/sites-available/%(project_domain)s' % env)
    with cd('/etc/apache2/sites-available'):
         sudo('a2ensite %(project_domain)s' % env) 
于 2010-04-18T06:52:29.320 回答
2

您可能想尝试使用cd 上下文管理器。您的字符串插值可能也有问题。

def install_site():
    # Add the virtualhost file to apache
    require('release', provided_by=[deploy, setup])

    with cd('%s/releases/%s/%s' % (path, release, release)):
        sudo('cp %s/%s/%s /etc/apache2/sites-available/%s' % (project_name, virtualhost_path, project_domain, project_domain))

    with cd('/etc/apache2/sites-available'):
        sudo('a2ensite %s' % project_domain)
于 2010-04-18T01:04:15.180 回答
0

问题已修复,注意到“hg archive ..”命令的某些内容,它会将 repo 压缩/压缩 2 层深

local('hg archive --type=tgz %(release)s.tar.gz' % {'release': env.release})

结果 20100418105144.tar.gz 当你打开时,它的结构如下:

20100418105144.tar.gz
/20100418105144
/repo

于 2010-04-18T09:16:18.647 回答