zoukankan      html  css  js  c++  java
  • Deploying with Fabric¶

    Deploying with Fabric — Flask 0.9-dev documentation

    Deploying with Fabric

    Fabric is a tool for Python similar to Makefiles but with the ability
    to execute commands on a remote server. In combination with a properly
    set up Python package (Larger Applications) and a good concept for
    configurations (Configuration Handling) it is very easy to deploy Flask
    applications to external servers.

    Before we get started, here a quick checklist of things we have to ensure
    upfront:

    • Fabric 1.0 has to be installed locally. This tutorial assumes the
      latest version of Fabric.
    • The application already has to be a package and requires a working
      setup.py file (Deploying with Distribute).
    • In the following example we are using mod_wsgi for the remote
      servers. You can of course use your own favourite server there, but
      for this example we chose Apache + mod_wsgi because it’s very easy
      to setup and has a simple way to reload applications without root
      access.

    Creating the first Fabfile

    A fabfile is what controls what Fabric executes. It is named fabfile.py
    and executed by the fab command. All the functions defined in that file
    will show up as fab subcommands. They are executed on one or more
    hosts. These hosts can be defined either in the fabfile or on the command
    line. In this case we will add them to the fabfile.

    This is a basic first example that has the ability to upload the current
    sourcecode to the server and install it into a pre-existing
    virtual environment:

    from fabric.api import *
    
    # the user to use for the remote commands
    env.user = 'appuser'
    # the servers where the commands are executed
    env.hosts = ['server1.example.com', 'server2.example.com']
    
    def pack():
        # create a new source distribution as tarball
        local('python setup.py sdist --formats=gztar', capture=False)
    
  • 相关阅读:
    5 静态链接和动态链接
    4 程序编译与链接
    3.死锁
    2.调度算法
    1 select,poll和epoll
    python语言特性
    python动态规划
    python语言编程算法
    链表
    认识黑客常用的入侵方法
  • 原文地址:https://www.cnblogs.com/lexus/p/2404269.html
Copyright © 2011-2022 走看看