1

ファブリック展開スクリプトの変更に問題があります。静的メディアをホストするための破損しやすいNFSマウントの使用から、すべての静的メディアをホストおよび処理する別のWebサーバーの使用に切り替えています。

目標は、デプロイする環境(test、prodなど)に関係なく、upload_static_contentコマンドが静的メディアサーバーでのみ実行されるようにすることです。今、私たちが実行すれば、fab test upload_static_contentすべてが完璧に機能します。静的コンテンツは、正しいディレクトリの正しいサーバーに配置されます。ただし、fad test deploy静的コンテンツを実行すると、目的のサーバーではなくテストWebサーバーに配置されます。

def test():
    ...
    env.hosts=testhosts

def prod():
    ...
    env.hosts=prodhosts

def deploy():
    # Do some deployment stuff
    ...
    upload_static_content()
    ...

@hosts([static_server,])
@run_once
def upload_static_content()
    # Upload static content to a different server
    ...
4

1 に答える 1

1

Fabric 1.3で導入された実行機能を試しましたか?@hostsデコレータを尊重する必要があります。

def deploy():
    # Do some deployment stuff
    ...
    execute(upload_static_content)

ドキュメントは次のとおりです。

http://docs.fabfile.org/en/1.4.2/usage/execution.html#intelligently-executing-tasks-with-execute

于 2012-07-06T17:48:38.417 に答える