我想部署我的代碼在本地主機和我的活動版本爲此自動化我使用結構。我的基本結構文件如下所示:django fabric設置部署主機
def localhost():
"Use the local virtual server"
env.hosts = ['127.0.0.1']
env.user = 'user'
env.path = '/var/www/html/{}'.format(env['project_name'])
env.virtualhost_path = env.path
def webserver():
"Use the actual webserver"
env.hosts = ['www.example.com']
env.user = 'username'
env.path = '/var/www/html/{}'.format(env['project_name'])
env.virtualhost_path = env.path
def setup():
require('hosts', provided_by=[localhost])
require('path')
sudo("apt-get update -y")
sudo("apt-get install git -y")
sudo("apt-get install postgresql libpq-dev python-dev python-pip -y")
sudo("apt-get install redis-server -y")
sudo("apt-get install nginx -y")
sudo('aptitude install -y python-setuptools')
sudo('apt-get install python-pip')
sudo('pip install virtualenv virtualenvwrapper')
現在我只想部署到本地計算機。當我這樣做,它給了我錯誤的說
The command 'setup' failed because the following required environment variable was not defined:
hosts
Try running the following command prior to this one, to fix the problem:
localhost
什麼provided_by=([localhost])
在這裏做。我想它應該提供像本地主機和用戶一樣的信息。
爲什麼我得到這個錯誤? 需要幫助