Browse Source

update other types of site to proxy

bugfixes
harshadyeola 10 years ago
parent
commit
e83289cf21
  1. 36
      ee/cli/plugins/site.py
  2. 4
      ee/cli/plugins/site_functions.py
  3. 2
      ee/cli/templates/virtualconf.mustache

36
ee/cli/plugins/site.py

@ -654,6 +654,8 @@ class EESiteUpdateController(CementBaseController):
dict(help='Use PageSpeed for site',
action='store' or 'store_const',
choices=('on', 'off'), const='on', nargs='?')),
(['--proxy'],
dict(help="update to prxy site", nargs='+')),
(['--all'],
dict(help="update all sites", action='store_true')),
]
@ -701,6 +703,21 @@ class EESiteUpdateController(CementBaseController):
Log.error(self, "Please provide valid options combination for"
" site update")
if stype is None and pargs.proxy:
stype, cache = 'proxy', ''
proxyinfo = pargs.proxy[0].strip()
if not proxyinfo:
Log.error(self, "Please provide proxy server host information")
proxyinfo = proxyinfo.split(':')
host = proxyinfo[0].strip()
port = '80' if len(proxyinfo) < 2 else proxyinfo[1].strip()
elif stype is None and not pargs.proxy:
stype, cache = 'html', 'basic'
elif stype and pargs.proxy:
Log.error(self, "--proxy can not be used with other site types")
if (pargs.proxy and (pargs.pagespeed or pargs.hhvm)):
Log.error(self, "Proxy site can not run on pagespeed or hhvm")
if not pargs.site_name:
try:
while not pargs.site_name:
@ -757,6 +774,18 @@ class EESiteUpdateController(CementBaseController):
format(oldsitetype, oldcachetype, stype, cache))
return 1
if stype == 'proxy':
data['site_name'] = ee_domain
data['www_domain'] = ee_www_domain
data['proxy'] = True
data['host'] = host
data['port'] = port
pagespeed = False
hhvm = False
data['webroot'] = ee_site_webroot
data['currsitetype'] = oldsitetype
data['currcachetype'] = oldcachetype
if stype == 'php':
data = dict(site_name=ee_domain, www_domain=ee_www_domain,
static=False, basic=True, wp=False, w3tc=False,
@ -926,6 +955,13 @@ class EESiteUpdateController(CementBaseController):
"`tail /var/log/ee/ee.log` & Try Again!!!")
return 1
if 'proxy' in data.keys() and data['proxy']:
updateSiteInfo(self, ee_domain, stype=stype, cache=cache,
hhvm=hhvm, pagespeed=pagespeed)
Log.info(self, "Successfully updated site"
" http://{0}".format(ee_domain))
return 0
# Update pagespeed config
if pargs.pagespeed:
operateOnPagespeed(self, data)

4
ee/cli/plugins/site_functions.py

@ -520,7 +520,7 @@ def sitebackup(self, data):
EEFileUtils.copyfile(self, '/etc/nginx/sites-available/{0}'
.format(data['site_name']), backup_path)
if data['currsitetype'] in ['html', 'php', 'mysql']:
if data['currsitetype'] in ['html', 'php', 'proxy', 'mysql']:
Log.info(self, "Backing up Webroot \t\t", end='')
EEFileUtils.mvfile(self, ee_site_webroot + '/htdocs', backup_path)
Log.info(self, "[" + Log.ENDC + "Done" + Log.OKBLUE + "]")
@ -544,7 +544,7 @@ def sitebackup(self, data):
raise SiteError("mysqldump failed to backup database")
Log.info(self, "[" + Log.ENDC + "Done" + Log.OKBLUE + "]")
# move wp-config.php/ee-config.php to backup
if data['currsitetype'] in ['mysql']:
if data['currsitetype'] in ['mysql', 'proxy']:
EEFileUtils.mvfile(self, configfiles[0], backup_path)
else:
EEFileUtils.copyfile(self, configfiles[0], backup_path)

2
ee/cli/templates/virtualconf.mustache

@ -19,7 +19,7 @@ server {
{{#proxy}}
add_header X-Proxy-Cache $upstream_cache_status;
location / {
proxy_pass {{host}}:{{port}};
proxy_pass http://{{host}}:{{port}};
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;

Loading…
Cancel
Save