Browse Source

Added ee stack update command

release/v3.3.0
gau1991 10 years ago
parent
commit
d9cfd46e07
  1. 44
      ee/cli/plugins/site.py
  2. 13
      ee/cli/plugins/stack.py
  3. 57
      ee/cli/templates/redis.mustache

44
ee/cli/plugins/site.py

@ -751,6 +751,8 @@ class EESiteUpdateController(CementBaseController):
dict(help="update to wpfc cache", action='store_true')),
(['--wpsc'],
dict(help="update to wpsc cache", action='store_true')),
(['--redis'],
dict(help="update to redis cache", action='store_true')),
(['--hhvm'],
dict(help='Use HHVM for site',
action='store' or 'store_const',
@ -781,7 +783,7 @@ class EESiteUpdateController(CementBaseController):
if not (pargs.php or
pargs.mysql or pargs.wp or pargs.wpsubdir or
pargs.wpsubdomain or pargs.w3tc or pargs.wpfc or
pargs.wpsc or pargs.hhvm or pargs.pagespeed):
pargs.wpsc or pargs.hhvm or pargs.pagespeed or pargs.redis):
Log.error(self, "Please provide options to update sites.")
if pargs.all:
@ -897,7 +899,7 @@ class EESiteUpdateController(CementBaseController):
if stype == 'php':
data = dict(site_name=ee_domain, www_domain=ee_www_domain,
static=False, basic=True, wp=False, w3tc=False,
wpfc=False, wpsc=False, multisite=False,
wpfc=False, wpsc=False, redis=False, multisite=False,
wpsubdir=False, webroot=ee_site_webroot,
currsitetype=oldsitetype, currcachetype=oldcachetype)
@ -905,7 +907,7 @@ class EESiteUpdateController(CementBaseController):
data = dict(site_name=ee_domain, www_domain=ee_www_domain,
static=False, basic=True, wp=False, w3tc=False,
wpfc=False, wpsc=False, multisite=False,
wpfc=False, wpsc=False, redis=False, multisite=False,
wpsubdir=False, webroot=ee_site_webroot,
ee_db_name='', ee_db_user='', ee_db_pass='',
ee_db_host='',
@ -1068,6 +1070,21 @@ class EESiteUpdateController(CementBaseController):
data['pagespeed'] = True
pagespeed = True
if data['currcachetype'] != 'redis' and pargs.redis:
if (not pargs.experimental):
Log.info(self, "Redis is experimental feature and it may not"
" work with all plugins of your site.\nYou can "
"disable it by changing cache type later.\nDo you wish"
" to enable Redis now for {0}?".format(ee_domain))
# Check prompt
check_prompt = input("Type \"y\" to continue [n]:")
if check_prompt != "Y" and check_prompt != "y":
Log.info(self, "Not using Redis for site")
data['redis'] = False
data['basic'] = True
cache = 'basic'
if ((hhvm is old_hhvm) and (pagespeed is old_pagespeed) and
(stype == oldsitetype and cache == oldcachetype)):
return 1
@ -1206,6 +1223,16 @@ class EESiteUpdateController(CementBaseController):
" `tail /var/log/ee/ee.log` & Try Again!!!")
return 1
if oldcachetype == 'redis' and not data['rediss']:
try:
uninstallwp_plugin(self, 'redis-cache', data)
except SiteError as e:
Log.debug(self, str(e))
Log.info(self, Log.FAIL + "Update site failed."
"Check logs for reason"
" `tail /var/log/ee/ee.log` & Try Again!!!")
return 1
if (oldcachetype != 'w3tc' or oldcachetype != 'wpfc') and (data['w3tc']
or data['wpfc']):
try:
@ -1226,6 +1253,17 @@ class EESiteUpdateController(CementBaseController):
"Check logs for reason "
"`tail /var/log/ee/ee.log` & Try Again!!!")
return 1
if oldcachetype != 'redis' and data['redis']:
try:
installwp_plugin(self, 'redis-cache', data)
except SiteError as e:
Log.debug(self, str(e))
Log.info(self, Log.FAIL + "Update site failed."
"Check logs for reason "
"`tail /var/log/ee/ee.log` & Try Again!!!")
return 1
# Service Nginx Reload
if not EEService.reload_service(self, 'nginx'):
Log.error(self, "service nginx reload failed. "

13
ee/cli/plugins/stack.py

@ -522,6 +522,19 @@ class EEStackController(CementBaseController):
Log.error(self, "Failed to reload Nginx, please check "
"output of `nginx -t`")
if set(EEVariables.ee_redis).issubset(set(apt_packages)):
if os.path.isfile("/etc/nginx/nginx.conf") and (not
os.path.isfile("/etc/nginx/common/redis.conf")):
data = dict()
Log.debug(self, 'Writting the nginx configuration to '
'file /etc/nginx/common/redis.conf')
ee_nginx = open('/etc/nginx/common/php-hhvm.conf',
encoding='utf-8', mode='w')
self.app.render((data), 'redis.mustache',
out=ee_nginx)
ee_nginx.close()
if set(EEVariables.ee_php).issubset(set(apt_packages)):
# Create log directories
if not os.path.exists('/var/log/php5/'):

57
ee/cli/templates/redis.mustache

@ -0,0 +1,57 @@
# Redis NGINX CONFIGURATION
# DO NOT MODIFY, ALL CHANGES LOST AFTER UPDATE EasyEngine (ee)
set $skip_cache 0;
# POST requests and URL with a query string should always go to php
if ($request_method = POST) {
set $skip_cache 0;
}
if ($query_string != "") {
set $skip_cache 1;
}
# Don't cache URL containing the following segments
if ($request_uri ~* "(/wp-admin/|/xmlrpc.php|wp-.*.php|index.php|/feed/|sitemap(_index)?.xml|[a-z0-9_-]+-sitemap([0-9]+)?.xml)") {
set $skip_cache 1;
}
# Don't use the cache for logged in users or recent commenter
if ($http_cookie ~* "comment_author|wordpress_[a-f0-9]+|wp-postpass|wordpress_no_cache|wordpress_logged_in") {
set $skip_cache 1;
}
# Use cached or actual file if they exists, Otherwise pass request to WordPress
location / {
try_files $uri $uri/ /index.php?$args;
}
location /redis-fetch {
internal ;
set $redis_key $args;
redis_pass redis;
}
location /redis-store {
internal ;
set_unescape_uri $key $arg_key ;
redis2_query set $key $echo_request_body;
redis2_query expire $key 6h;
redis2_pass redis;
}
location ~ \.php$ {
set $key "nginx-cache:$scheme$request_method$host$request_uri";
try_files $uri =404;
srcache_fetch_skip $skip_cache;
srcache_store_skip $skip_cache;
srcache_response_cache_control off;
set_escape_uri $escaped_key $key;
srcache_fetch GET /redis-fetch $key;
srcache_store PUT /redis-store key=$escaped_key;
add_header X-Cache $srcache_fetch_status;
add_header X-Cache-2 $srcache_store_status;
include fastcgi_params;
fastcgi_pass php;
}
Loading…
Cancel
Save