首页 > 解决方案 > 使用 Fabric 在 DigitalOcean 上部署夹层站点

问题描述

我正在尝试部署我的夹层站点,并且一直在使用 CASE 1(到新服务器)遵循本教程

该过程安装virtualenvs,并在其中包含我的项目名称的目录,然后出现此错误:

[1xx.xx.xxx.xx] 输出:/home/~/.virtualenvs/blog_iq/bin/python 中的新 python 可执行文件 [1xx.xx.xxx.xx] 输出:安装 setuptools、pip、wheel...完成。[1xx.xx.xxx.xx]] 输出:[1xx.xx.xxx.xx]] rsync_project: rsync --exclude " .pyc" --exclude " .pyo" --exclude "*.db" --exclude ".DS_Store" --exclude ".coverage" --exclude "local_settings.py" --exclude "/static" --exclude "/.git" --exclude "/.hg" -pthrvz --rsh='ssh -p 22 ' C:\Users\~\Root\2blog\blog_iq\
user@1xx.xxx.xx:/home/user/mezzanine/blog_iq

[localhost] 本地:rsync --exclude " .pyc" --exclude " .pyo" --exclude "*.db" --exclude ".DS_Store" --exclude ".coverage" --exclude "local_settings.py" --exclude "/static" --exclude "/.git" --exclude "/.hg" -pthrvz --rsh='ssh -p 22 ' C:\Users\~\Root\2blog\blog_iq\
user@ 1xx.xxx.xx:/home/user/mezzanine/blog_iq

源和目标不能都是远程的。rsync 错误:main.c(1292) [Receiver=3.1.2] 处的语法或使用错误(代码 1)

致命错误:local() 在执行 'rsync --exclude " .pyc" --exclude " .pyo" --exclude "*.db" --exclude ".DS_Store" --exclude时遇到错误(返回代码 1)".coverage" --exclude "local_settings.py" --exclude "/static" --exclude "/.git" --exclude "/.hg" -pthrvz --rsh='ssh -p 22 ' C:\用户\~\Root\2blog\blog_iq\
user@1xx.xxx.xx:/home/user/mezzanine/blog_iq

中止。从 1xx.xxx.xx 断开连接...完成。

我很乐意发布在安装时由夹层生成的整个 fabfile.py,但它很长,除了寻找生成此打印输出的代码之外,我从未接触过它,它似乎在这里:

################
# Config setup #
################

if not hasattr(env, "proj_app"):
    env.proj_app = real_project_name("blog_iq")

conf = {}
if sys.argv[0].split(os.sep)[-1] in ("fab", "fab-script.py"):
    # Ensure we import settings from the current dir
    try:
        conf = import_module("%s.settings" % env.proj_app).FABRIC
        try:
            conf["HOSTS"][0]
        except (KeyError, ValueError):
            raise ImportError
    except (ImportError, AttributeError):
        print("Aborting, no hosts defined.")
        exit()


env.db_pass = conf.get("DB_PASS", None)
env.admin_pass = conf.get("ADMIN_PASS", None)
env.user = conf.get("SSH_USER", getuser())
env.password = conf.get("SSH_PASS", None)
env.key_filename = conf.get("SSH_KEY_PATH", None)
env.hosts = conf.get("HOSTS", [""])

env.proj_name = conf.get("PROJECT_NAME", env.proj_app)
env.venv_home = conf.get("VIRTUALENV_HOME", "/home/%s/.virtualenvs" % env.user)
env.venv_path = join(env.venv_home, env.proj_name)
env.proj_path = "/home/%s/mezzanine/%s" % (env.user, env.proj_name)
env.manage = "%s/bin/python %s/manage.py" % (env.venv_path, env.proj_path)
env.domains = conf.get("DOMAINS", [conf.get("LIVE_HOSTNAME", env.hosts[0])])
env.domains_nginx = " ".join(env.domains)
env.domains_regex = "|".join(env.domains)
env.domains_python = ", ".join(["'%s'" % s for s in env.domains])
env.ssl_disabled = "#" if len(env.domains) > 1 else ""
env.vcs_tools = ["git", "hg"]
env.deploy_tool = conf.get("DEPLOY_TOOL", "rsync")
env.reqs_path = conf.get("REQUIREMENTS_PATH", None)
env.locale = conf.get("LOCALE", "en_US.UTF-8")
env.num_workers = conf.get("NUM_WORKERS",
                           "multiprocessing.cpu_count() * 2 + 1")

env.secret_key = conf.get("SECRET_KEY", "")
env.nevercache_key = conf.get("NEVERCACHE_KEY", "")

if not env.secret_key:
    print("Aborting, no SECRET_KEY setting defined.")
    exit()


# Remote git repos need to be "bare" and reside separated from the project
if env.deploy_tool == "git":
    env.repo_path = "/home/%s/git/%s.git" % (env.user, env.proj_name)
else:
    env.repo_path = env.proj_path

和这里

def rsync_upload():
    """
    Uploads the project with rsync excluding some files and folders.
    """
    excludes = ["*.pyc", "*.pyo", "*.db", ".DS_Store", ".coverage",
                "local_settings.py", "/static", "/.git", "/.hg"]
    local_dir = os.getcwd() + os.sep
    return rsync_project(remote_dir=env.proj_path, local_dir=local_dir,
                         exclude=excludes)

标签: rsyncmezzanine

解决方案


不幸的是,由于该列,rsync解释C:为远程服务器。

我想你必须安装CygWinrsync然后使用类似 CygWin 的路径:/cygdrive/c/...


推荐阅读