示例#1
0
文件: backend.py 项目: ardnet/genesis
	def add_reverse_proxy(self, name, path, addr, port, block):
		w = Webapp()
		w.name = name
		w.stype = 'ReverseProxy'
		w.path = path
		w.addr = addr
		w.port = port
		w.dbengine = None
		w.dbname = None
		w.dbuser = None
		if not block:
			block = [
				nginx.Location('/admin/media/',
					nginx.Key('root', '/usr/lib/python2.7/site-packages/django/contrib')
				),
				nginx.Location('/',
					nginx.Key('proxy_set_header', 'X-Forwarded-For $proxy_add_x_forwarded_for'),
					nginx.Key('proxy_set_header', 'Host $http_host'),
					nginx.Key('proxy_redirect', 'off'),
					nginx.If('(!-f $request_filename)',
						nginx.Key('proxy_pass', 'unix:%s'%os.path.join(path, 'gunicorn.sock')),
						nginx.Key('break', '')
					)
				)
			]
		self.nginx_add(w, block)
		self.nginx_enable(w)
示例#2
0
文件: backend.py 项目: ardnet/genesis
		if wa.wa_plugin == 'Website' and php == '1' and addtoblock:
			addtoblock.extend(x for x in webapp.phpblock)
		elif wa.wa_plugin == 'Website' and php == '1':
			addtoblock = webapp.phpblock

		# Setup the webapp and create an nginx serverblock
		try:
			w = Webapp()
			w.name = name
			w.stype = wa.wa_plugin
			w.path = target_path
			w.addr = vars.getvalue('addr', 'localhost')
			w.port = vars.getvalue('port', '80')
			w.php = True if wa.php is True or php is '1' else False
			w.version = wa.version.rsplit('-', 1)[0] if wa.website_updates else None
			w.dbengine = dbinfo['engine'] if dbinfo else None
			w.dbname = dbinfo['name'] if dbinfo else None
			w.dbuser = dbinfo['user'] if dbinfo else None
			self.nginx_add(site=w, 
				add=addtoblock if addtoblock else webapp.addtoblock, 
				)
		except Exception, e:
			raise PartialError('nginx serverblock couldn\'t be written - '+str(e))

		try:
			cat.statusmsg('Running post-install configuration...')
			specialmsg = webapp.post_install(name, target_path, vars, dbinfo)
		except Exception, e:
			shutil.rmtree(target_path, True)
			self.nginx_remove(w, False)
			raise InstallError('Webapp config - '+str(e))