Skip to content

Commit 1c6b6a5

Browse files
author
gau1991
committed
Merge branch 'master' into stable
2 parents 1ca2b70 + 66544eb commit 1c6b6a5

File tree

14 files changed

+158
-66
lines changed

14 files changed

+158
-66
lines changed

CHANGELOG.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
v 3.0.9 - April 10, 2015
2+
- Fixed #483, now Xdebug is enabled during ee debug only and disabled by default
3+
- Introduced ee sync command to sync EasyEngine database with Site information
4+
- Minor fixes and improvement
5+
16
v 3.0.8 - April 9,2015
27
- Fixed regression issue introduced in 3.0.7
38

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ Update procedure for EasyEngine to latest version
2828
wget -qO ee rt.cx/ee && sudo bash ee
2929

3030
```
31-
#### Current version is 3.0.6
31+
#### If Current version is after than 3.0.6
3232
```
3333
ee update
3434
```

config/bash_completion.d/ee_auto.rc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ _ee_complete()
1111
# SETUP THE BASE LEVEL (everything after "ee")
1212
if [ $COMP_CWORD -eq 1 ]; then
1313
COMPREPLY=( $(compgen \
14-
-W "stack site debug clean secure import-slow-log log update" \
14+
-W "stack site debug clean secure import-slow-log log update sync" \
1515
-- $cur) )
1616

1717

@@ -143,7 +143,7 @@ _ee_complete()
143143
;;
144144
"delete")
145145
COMPREPLY=( $(compgen \
146-
-W "--db --files --all" \
146+
-W "--db --files --all --no-prompt" \
147147
-- $cur) )
148148
;;
149149
*)

config/ee.conf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,3 +74,9 @@ email =
7474
### `ee.cli.plugins.example` or from the file path
7575
### `/var/lib/ee/plugins/example.py`
7676
enable_plugin = true
77+
78+
[sync]
79+
### If enabled, load a plugin named `update` either from the Python module
80+
### `ee.cli.plugins.example` or from the file path
81+
### `/var/lib/ee/plugins/example.py`
82+
enable_plugin = true

ee/cli/plugins/debug.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
from ee.core.logging import Log
99
from ee.cli.plugins.site_functions import logwatch
1010
from ee.core.variables import EEVariables
11+
from ee.core.fileutils import EEFileUtils
1112
import os
1213
import configparser
1314
import glob
@@ -170,6 +171,12 @@ def debug_php(self):
170171
encoding='utf-8', mode='w')
171172
self.app.render((data), 'upstream.mustache', out=ee_nginx)
172173
ee_nginx.close()
174+
# Enable xdebug
175+
EEFileUtils.searchreplace(self, "/etc/php5/mods-available/"
176+
"xdebug.ini",
177+
";zend_extension",
178+
"zend_extension")
179+
173180
self.trigger_php = True
174181
self.trigger_nginx = True
175182
else:
@@ -190,6 +197,12 @@ def debug_php(self):
190197
encoding='utf-8', mode='w')
191198
self.app.render((data), 'upstream.mustache', out=ee_nginx)
192199
ee_nginx.close()
200+
# Disable xdebug
201+
EEFileUtils.searchreplace(self, "/etc/php5/mods-available/"
202+
"xdebug.ini",
203+
"zend_extension",
204+
";zend_extension")
205+
193206
self.trigger_php = True
194207
self.trigger_nginx = True
195208
else:
@@ -531,7 +544,7 @@ def default(self):
531544
EEService.reload_service(self, 'nginx')
532545
# Reload PHP
533546
if self.trigger_php:
534-
EEService.reload_service(self, 'php5-fpm')
547+
EEService.restart_service(self, 'php5-fpm')
535548

536549
if len(self.msg) > 0:
537550
if not self.app.pargs.interactive:

ee/cli/plugins/site.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ def ee_site_hook(app):
2020
from ee.core.database import init_db
2121
import ee.cli.plugins.models
2222
init_db(app)
23-
EESync(app).syncdbinfo()
2423

2524

2625
class EESiteController(CementBaseController):
@@ -579,7 +578,13 @@ def default(self):
579578
.format(ee_domain))
580579

581580
ee_auth = site_package_check(self, stype)
582-
sitebackup(self, data)
581+
582+
try:
583+
sitebackup(self, data)
584+
except Exception as e:
585+
Log.debug(self, str(e))
586+
Log.error(self, "Check logs for reason "
587+
"`tail /var/log/ee/ee.log` & Try Again!!!")
583588

584589
# setup NGINX configuration, and webroot
585590
try:
@@ -788,7 +793,7 @@ def default(self):
788793

789794
# Delete website database
790795
if self.app.pargs.db:
791-
if ee_db_name != 'deleted':
796+
if ee_db_name != 'deleted' and ee_db_name != '':
792797
if not self.app.pargs.no_prompt:
793798
ee_db_prompt = input('Are you sure, you want to delete'
794799
' database [y/N]: ')
@@ -807,7 +812,8 @@ def default(self):
807812
Log.info(self, "Deleted Database successfully.")
808813
else:
809814
mark_db_deleted = True
810-
Log.info(self, "Database seems to be deleted.")
815+
Log.info(self, "Does not seems to have database for this site."
816+
)
811817

812818
# Delete webroot
813819
if self.app.pargs.files:

ee/cli/plugins/site_functions.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -506,8 +506,11 @@ def sitebackup(self, data):
506506
.split(')')[0].strip().replace('\'', ''))
507507
Log.info(self, 'Backing up database \t\t', end='')
508508
try:
509-
EEShellExec.cmd_exec(self, "mysqldump {0} > {1}/{0}.sql"
510-
.format(ee_db_name, backup_path))
509+
if not EEShellExec.cmd_exec(self, "mysqldump {0} > {1}/{0}.sql"
510+
.format(ee_db_name, backup_path)):
511+
Log.info(self,
512+
"[" + Log.ENDC + Log.FAIL + "Fail" + Log.OKBLUE + "]")
513+
raise SiteError("mysqldump failed to backup database")
511514
except CommandExecutionError as e:
512515
Log.info(self, "[" + Log.ENDC + "Fail" + Log.OKBLUE + "]")
513516
raise SiteError("mysqldump failed to backup database")

ee/cli/plugins/sitedb.py

Lines changed: 0 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
from sqlalchemy.ext.declarative import declarative_base
55
from ee.core.logging import Log
66
from ee.core.database import db_session
7-
from ee.core.fileutils import EEFileUtils
87
from ee.cli.plugins.models import SiteDB
98
import sys
109
import glob
@@ -117,47 +116,3 @@ def getAllsites(self):
117116
except Exception as e:
118117
Log.debug(self, "{0}".format(e))
119118
Log.error(self, "Unable to query database")
120-
121-
122-
class EESync(object):
123-
124-
def __init__(self, app):
125-
self.app = app
126-
127-
def syncdbinfo(self):
128-
"""
129-
1. reads database information from wp/ee-config.php
130-
2. updates records into ee database accordingly.
131-
"""
132-
sites = getAllsites(self)
133-
if not sites:
134-
pass
135-
for site in sites:
136-
if site.site_type in ['mysql', 'wp', 'wpsubdir', 'wpsubdomain']:
137-
ee_site_webroot = site.site_path
138-
# Read config files
139-
configfiles = glob.glob(ee_site_webroot + '/*-config.php')
140-
if configfiles:
141-
if EEFileUtils.isexist(self, configfiles[0]):
142-
ee_db_name = (EEFileUtils.grep(self, configfiles[0],
143-
'DB_NAME').split(',')[1]
144-
.split(')')[0].strip().replace('\'', ''))
145-
ee_db_user = (EEFileUtils.grep(self, configfiles[0],
146-
'DB_USER').split(',')[1]
147-
.split(')')[0].strip().replace('\'', ''))
148-
ee_db_pass = (EEFileUtils.grep(self, configfiles[0],
149-
'DB_PASSWORD').split(',')[1]
150-
.split(')')[0].strip().replace('\'', ''))
151-
ee_db_host = (EEFileUtils.grep(self, configfiles[0],
152-
'DB_HOST').split(',')[1]
153-
.split(')')[0].strip().replace('\'', ''))
154-
155-
if site.db_name != ee_db_name:
156-
# update records if any mismatch found
157-
Log.debug(self, "Updating {0}"
158-
.format(site.sitename))
159-
updateSiteInfo(self, site.sitename,
160-
db_name=ee_db_name,
161-
db_user=ee_db_user,
162-
db_password=ee_db_pass,
163-
db_host=ee_db_host)

ee/cli/plugins/stack.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -490,6 +490,12 @@ def post_pref(self, apt_packages, packages):
490490
"_trigger] = on \nphp_admin_flag[xdebug."
491491
"profiler_enable] = off\n")
492492

493+
# Disable xdebug
494+
EEFileUtils.searchreplace(self, "/etc/php5/mods-available/"
495+
"xdebug.ini",
496+
"zend_extension",
497+
";zend_extension")
498+
493499
# PHP and Debug pull configuration
494500
if not os.path.exists('{0}22222/htdocs/fpm/status/'
495501
.format(EEVariables.ee_webroot)):

ee/cli/plugins/sync.py

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
from cement.core.controller import CementBaseController, expose
2+
from cement.core import handler, hook
3+
from ee.core.fileutils import EEFileUtils
4+
from ee.cli.plugins.sitedb import *
5+
from ee.core.mysql import *
6+
from ee.core.logging import Log
7+
8+
9+
def ee_sync_hook(app):
10+
# do something with the ``app`` object here.
11+
pass
12+
13+
14+
class EESyncController(CementBaseController):
15+
class Meta:
16+
label = 'sync'
17+
stacked_on = 'base'
18+
stacked_type = 'nested'
19+
description = 'synchronize EasyEngine database'
20+
21+
@expose(hide=True)
22+
def default(self):
23+
self.sync()
24+
25+
@expose(hide=True)
26+
def sync(self):
27+
"""
28+
1. reads database information from wp/ee-config.php
29+
2. updates records into ee database accordingly.
30+
"""
31+
Log.info(self, "Synchronizing ee database, please wait ....")
32+
sites = getAllsites(self)
33+
if not sites:
34+
pass
35+
for site in sites:
36+
if site.site_type in ['mysql', 'wp', 'wpsubdir', 'wpsubdomain']:
37+
ee_site_webroot = site.site_path
38+
# Read config files
39+
configfiles = glob.glob(ee_site_webroot + '/*-config.php')
40+
if configfiles:
41+
if EEFileUtils.isexist(self, configfiles[0]):
42+
ee_db_name = (EEFileUtils.grep(self, configfiles[0],
43+
'DB_NAME').split(',')[1]
44+
.split(')')[0].strip().replace('\'', ''))
45+
ee_db_user = (EEFileUtils.grep(self, configfiles[0],
46+
'DB_USER').split(',')[1]
47+
.split(')')[0].strip().replace('\'', ''))
48+
ee_db_pass = (EEFileUtils.grep(self, configfiles[0],
49+
'DB_PASSWORD').split(',')[1]
50+
.split(')')[0].strip().replace('\'', ''))
51+
ee_db_host = (EEFileUtils.grep(self, configfiles[0],
52+
'DB_HOST').split(',')[1]
53+
.split(')')[0].strip().replace('\'', ''))
54+
55+
# Check if database really exist
56+
try:
57+
if not EEMysql.check_db_exists(self, ee_db_name):
58+
# Mark it as deleted if not exist
59+
ee_db_name = 'deleted'
60+
ee_db_user = 'deleted'
61+
ee_db_pass = 'deleted'
62+
except StatementExcecutionError as e:
63+
Log.debug(self, str(e))
64+
except Exception as e:
65+
Log.debug(self, str(e))
66+
67+
if site.db_name != ee_db_name:
68+
# update records if any mismatch found
69+
Log.debug(self, "Updating ee db record for {0}"
70+
.format(site.sitename))
71+
updateSiteInfo(self, site.sitename,
72+
db_name=ee_db_name,
73+
db_user=ee_db_user,
74+
db_password=ee_db_pass,
75+
db_host=ee_db_host)
76+
77+
78+
def load(app):
79+
# register the plugin class.. this only happens if the plugin is enabled
80+
handler.register(EESyncController)
81+
# register a hook (function) to run after arguments are parsed.
82+
hook.register('post_argument_parsing', ee_sync_hook)

0 commit comments

Comments
 (0)