Browse Source

#389 initial fix

bugfixes
harshadyeola 10 years ago
parent
commit
9bf9582e8f
  1. 37
      ee/cli/plugins/site.py
  2. 9
      ee/cli/plugins/site_functions.py
  3. 18
      ee/cli/templates/virtualconf.mustache

37
ee/cli/plugins/site.py

@ -344,7 +344,9 @@ class EESiteCreateController(CementBaseController):
dict(help="provide email address for wordpress site")),
(['--pass'],
dict(help="provide password for wordpress user",
dest='wppass'))
dest='wppass')),
(['--proxy'],
dict(help="create proxy for site", nargs='+'))
]
@expose(hide=True)
@ -352,12 +354,21 @@ class EESiteCreateController(CementBaseController):
# self.app.render((data), 'default.mustache')
# Check domain name validation
data = dict()
host, port = None, None
try:
stype, cache = detSitePar(vars(self.app.pargs))
except RuntimeError as e:
Log.debug(self, str(e))
Log.error(self, "Please provide valid options to creating site")
if stype is None and self.app.pargs.proxy:
stype, cache = 'proxy', ''
proxyinfo = self.app.pargs.proxy[0].split(':')
host = proxyinfo[0]
port = '80' if len(proxyinfo) < 2 else proxyinfo[1]
elif stype is None and not self.app.pargs.proxy:
stype, cache = 'html', 'basic'
if not self.app.pargs.site_name:
try:
while not self.app.pargs.site_name:
@ -384,6 +395,14 @@ class EESiteCreateController(CementBaseController):
Log.error(self, "Nginx configuration /etc/nginx/sites-available/"
"{0} already exists".format(ee_domain))
if stype == 'proxy':
data['site_name'] = ee_domain
data['www_domain'] = ee_www_domain
data['proxy'] = True
data['host'] = host
data['port'] = port
ee_site_webroot = ""
if stype in ['html', 'php']:
data = dict(site_name=ee_domain, www_domain=ee_www_domain,
static=True, basic=False, wp=False, w3tc=False,
@ -393,6 +412,7 @@ class EESiteCreateController(CementBaseController):
if stype == 'php':
data['static'] = False
data['basic'] = True
elif stype in ['mysql', 'wp', 'wpsubdir', 'wpsubdomain']:
data = dict(site_name=ee_domain, www_domain=ee_www_domain,
@ -413,6 +433,8 @@ class EESiteCreateController(CementBaseController):
data['multisite'] = True
if stype == 'wpsubdir':
data['wpsubdir'] = True
else:
pass
if stype == "html" and self.app.pargs.hhvm:
Log.error(self, "Can not create HTML site with HHVM")
@ -431,13 +453,12 @@ class EESiteCreateController(CementBaseController):
data['pagespeed'] = False
pagespeed = 0
if not data:
self.app.args.print_help()
self.app.close(1)
# if not data:
# self.app.args.print_help()
# self.app.close(1)
# Check rerequired packages are installed or not
ee_auth = site_package_check(self, stype)
try:
try:
# setup NGINX configuration, and webroot
@ -452,12 +473,18 @@ class EESiteCreateController(CementBaseController):
Log.error(self, "Check logs for reason "
"`tail /var/log/ee/ee.log` & Try Again!!!")
if 'proxy' in data.keys() and data['proxy']:
addNewSite(self, ee_domain, stype, cache, ee_site_webroot)
Log.info(self, "Successfully created site"
" http://{0}".format(ee_domain))
return
# Update pagespeed config
if self.app.pargs.pagespeed:
operateOnPagespeed(self, data)
addNewSite(self, ee_domain, stype, cache, ee_site_webroot,
hhvm=hhvm, pagespeed=pagespeed)
# Setup database for MySQL site
if 'ee_db_name' in data.keys() and not data['wp']:
try:

9
ee/cli/plugins/site_functions.py

@ -52,7 +52,7 @@ def check_domain_exists(self, domain):
def setupdomain(self, data):
ee_domain_name = data['site_name']
ee_site_webroot = data['webroot']
ee_site_webroot = data['webroot'] if 'webroot' in data.keys() else ''
# Check if nginx configuration already exists
# if os.path.isfile('/etc/nginx/sites-available/{0}'
@ -90,6 +90,9 @@ def setupdomain(self, data):
raise SiteError("created nginx configuration failed for site."
" check with `nginx -t`")
if 'proxy' in data.keys() and data['proxy']:
return
# create symbolic link for
EEFileUtils.create_symlink(self, ['/etc/nginx/sites-available/{0}'
.format(ee_domain_name),
@ -797,8 +800,8 @@ def detSitePar(opts):
raise RuntimeError("could not determine site and cache type")
else:
if not typelist and not cachelist:
sitetype = 'html'
cachetype = 'basic'
sitetype = None
cachetype = None
elif (not typelist) and cachelist:
sitetype = 'wp'
cachetype = cachelist[0]

18
ee/cli/templates/virtualconf.mustache

@ -15,11 +15,24 @@ server {
access_log /var/log/nginx/{{site_name}}.access.log {{^static}}rt_cache{{/static}};
error_log /var/log/nginx/{{site_name}}.error.log;
{{#proxy}}
add_header X-Proxy-Cache $upstream_cache_status;
location / {
proxy_pass {{host}}:{{port}};
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
{{/proxy}}
{{^proxy}}
{{^vma}}{{^rc}}root {{webroot}}/htdocs;{{/rc}}{{/vma}}
{{#vma}}root /var/www/22222/htdocs/vimbadmin/public;{{/vma}}
{{#rc}}root /var/www/roundcubemail/htdocs/;{{/rc}}
index {{^static}}index.php{{/static}} index.html index.htm;
{{^proxy}}index {{^static}}index.php{{/static}} index.html index.htm;{{/proxy}}
{{#static}}
location / {
@ -30,6 +43,7 @@ server {
{{^static}}include {{^hhvm}}{{#basic}}common/php.conf;{{/basic}}{{#w3tc}}common/w3tc.conf;{{/w3tc}}{{#wpfc}}common/wpfc.conf;{{/wpfc}} {{#wpsc}}common/wpsc.conf;{{/wpsc}} {{/hhvm}}{{#hhvm}}{{#basic}}common/php-hhvm.conf;{{/basic}}{{#w3tc}}common/w3tc-hhvm.conf;{{/w3tc}}{{#wpfc}}common/wpfc-hhvm.conf;{{/wpfc}} {{#wpsc}}common/wpsc-hhvm.conf;{{/wpsc}} {{/hhvm}}
{{#wpsubdir}}include common/wpsubdir.conf;{{/wpsubdir}}{{/static}}
{{#wp}}include common/wpcommon.conf;{{/wp}}
include common/locations.conf;
{{^proxy}}include common/locations.conf;{{/proxy}}
{{^vma}}{{^rc}}include {{webroot}}/conf/nginx/*.conf;{{/rc}}{{/vma}}
{{/proxy}}
}

Loading…
Cancel
Save