0
讓我們考慮這個fabfile面料 - 項目路徑環境
def syncdb():
print(green("Database Synchronization ..."))
with cd('/var/www/project'):
sudo('python manage.py syncdb', user='www-data')
def colstat():
print(green("Collecting Static Files..."))
with cd('/var/www/project'):
sudo('python manage.py collectstatic --noinput', user='www-data')
def httpdrst():
print(green("Restarting Apache..."))
sudo('apachectl restart')
def srefresh():
colstat()
syncdb()
httpdrst()
的srefresh
指令要求所有的人,其中某些with cd(...)
什麼是有這樣的「CD路徑」的最佳途徑在一個變量?
def colstat():
with cd(env.remote['path']):
def srefresh():
env.remote['path'] = '/var/www/project'
colstat()
syncdb()
httpdrst()
這樣的事情?
作業可能無法適用於織物,但... – enderskill 2012-03-29 15:13:20
這應該工作在織物上就好了。如果您仍然想用'fab command'調用它們而不需要指定參數,只需給它們一個默認值即可。 – Wilduck 2012-03-29 15:59:13
工作,但問題是我不能獨立調用'syncdb','colstat' – 2012-03-30 11:26:01