Browse Source

minimizing Downtime

develop
Prabuddha Chakraborty 9 years ago
parent
commit
aca34c6ec9
  1. 14
      ee/cli/plugins/stack.py
  2. 33
      ee/core/aptget.py

14
ee/cli/plugins/stack.py

@ -1699,15 +1699,21 @@ class EEStackController(CementBaseController):
'operation.')
ee_prompt = input("Type \"YES\" or \"yes\" to continue [n]: ")
if ee_prompt == 'YES' or ee_prompt == 'yes':
Log.info(self,"Initializing... Please Wait")
EERepo.remove(self, repo_url=EEVariables.ee_nginx_dev_repo)
if EEAptGet.download_only(self,EEVariables.ee_nginx,EEVariables.ee_nginx_repo,EEVariables.ee_nginx_key):
EEService.stop_service(self, 'nginx')
Log.debug(self, "Removing apt_packages variable of Nginx")
Log.debug(self, "Removing apt_packages variable of NGINX")
Log.info(self, "Removing packages, please wait...")
EEAptGet.remove(self, EEVariables.ee_nginx_dev)
EEAptGet.auto_remove(self)
Log.info(self, "Removing repository for NGINX MAINLINE,")
EERepo.remove(self, repo_url=EEVariables.ee_nginx_dev_repo)
Log.info(self, "Successfully removed packages")
apt_packages = apt_packages + EEVariables.ee_nginx
else:
#revert the changes
EERepo.add(self, repo_url=EEVariables.ee_nginx_dev_repo)
Log.error(self,"Skipped installing NGINX Stable")
if self.app.pargs.nginxmainline:
if EEVariables.ee_nginx_dev_repo == None:
@ -1731,6 +1737,8 @@ class EEStackController(CementBaseController):
'operation.')
ee_prompt = input("Type \"YES\" or \"yes\" to continue [n]: ")
if ee_prompt == 'YES' or ee_prompt == 'yes':
Log.info(self,"Initializing... Please Wait")
if EEAptGet.download_only(self,EEVariables.ee_nginx_dev,EEVariables.ee_nginx_dev_repo,EEVariables.ee_nginx_key):
EEService.stop_service(self, 'nginx')
Log.debug(self, "Removing apt_packages variable of Nginx")
Log.info(self, "Removing packages, please wait...")
@ -1738,6 +1746,8 @@ class EEStackController(CementBaseController):
EEAptGet.auto_remove(self)
Log.info(self, "Successfully removed packages")
apt_packages = apt_packages + EEVariables.ee_nginx_dev
else:
Log.error(self,"Skipped installing NGINX Mainline")
if self.app.pargs.php:
Log.debug(self, "Setting apt_packages variable for PHP")

33
ee/core/aptget.py

@ -195,3 +195,36 @@ class EEAptGet():
return True
# apt_cache.close()
return False
def download_only(self,package_name,repo_url=None,repo_key=None):
"""
Similar to `apt-get install --download-only`
"""
try:
with open('/var/log/ee/ee.log', 'a') as f:
if repo_url is not None:
EERepo.add(self, repo_url=repo_url)
if repo_key is not None:
EERepo.add_key(self, repo_key)
proc = subprocess.Popen("DEBIAN_FRONTEND=noninteractive "
"apt-get install -o "
"Dpkg::Options::=\"--force-confdef\""
" -o "
"Dpkg::Options::=\"--force-confold\""
" -y --download-only {0}"
.format(package_name), shell=True,
stdin=None, stdout=f, stderr=f,
executable="/bin/bash")
proc.wait()
if proc.returncode == 0:
return True
else:
Log.error(self,"Error in fetching dpkg package.\nReverting changes ..",False)
if repo_url is not None:
EERepo.remove(self, repo_url=repo_url)
return False
except Exception as e:
Log.error(self, "Error while downloading packages, "
"apt-get exited with error")

Loading…
Cancel
Save