summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Walter Purcaro <vuolter@gmail.com> 2014-06-28 20:20:16 +0200
committerGravatar Walter Purcaro <vuolter@gmail.com> 2014-06-28 20:20:16 +0200
commitb6630d2c4d0b4b511282e228530ea6053647d48c (patch)
tree49f2a295d65eb82875cc0fa2781ae630cf5459b3
parent[Webui] Notify update version when a pyload update is available (diff)
downloadpyload-b6630d2c4d0b4b511282e228530ea6053647d48c.tar.xz
Improve web server choosing
-rw-r--r--module/setup.py23
-rw-r--r--module/web/ServerThread.py54
-rw-r--r--module/web/webinterface.py2
3 files changed, 43 insertions, 36 deletions
diff --git a/module/setup.py b/module/setup.py
index f7a26e15f..0127b629a 100644
--- a/module/setup.py
+++ b/module/setup.py
@@ -237,6 +237,8 @@ class Setup():
self.print_dep("jinja2", jinja)
beaker = self.check_module("beaker")
self.print_dep("beaker", beaker)
+ bjoern = self.check_module("bjoern")
+ self.print_dep("bjoern", bjoern)
web = sqlite and beaker
@@ -296,21 +298,26 @@ class Setup():
self.config["webinterface"]["port"] = self.ask(_("Port"), "8000")
print ""
print _("pyLoad offers several server backends, now following a short explanation.")
- print "builtin:", _("Default server, best choice if you dont know which one to choose.")
- print "threaded:", _("This server offers SSL and is a good alternative to builtin.")
+ print "builtin:", _("Default server; best choice if you plan to use pyLoad just for you.")
+ print "threaded:", _("Support SSL connection and can serve simultaneously more client flawlessly.")
print "fastcgi:", _(
- "Can be used by apache, lighttpd, requires you to configure them, which is not too easy job.")
- print "lightweight:", _("Very fast alternative written in C, requires libev and linux knowlegde.")
- print "\t", _("Get it from here: https://github.com/jonashaag/bjoern, compile it")
- print "\t", _("and copy bjoern.so to module/lib")
+ "Can be used by apache, lighttpd, etc.; needs to be properly configured before.")
+ if os.name != "nt":
+ print "lightweight:", _("Very fast alternative to builtin; requires libev and bjoern packages.")
print
print _(
"Attention: In some rare cases the builtin server is not working, if you notice problems with the webinterface")
print _("come back here and change the builtin server to the threaded one here.")
- self.config["webinterface"]["server"] = self.ask(_("Server"), "builtin",
- ["builtin", "threaded", "fastcgi", "lightweight"])
+ if os.name == "nt":
+ servers = ["builtin", "threaded", "fastcgi"]
+ default = "threaded"
+ else:
+ servers = ["builtin", "threaded", "fastcgi", "lightweight"]
+ default = "lightweight" if self.check_module("bjoern") else "builtin"
+
+ self.config["webinterface"]["server"] = self.ask(_("Server"), default, servers)
def conf_ssl(self):
diff --git a/module/web/ServerThread.py b/module/web/ServerThread.py
index 84667e5f6..451517d71 100644
--- a/module/web/ServerThread.py
+++ b/module/web/ServerThread.py
@@ -30,45 +30,45 @@ class WebServer(threading.Thread):
import webinterface
global webinterface
- if self.https:
- if not exists(self.cert) or not exists(self.key):
- log.warning(_("SSL certificates not found."))
- self.https = False
+ reset = False
+
+ if self.https and (not exists(self.cert) or not exists(self.key)):
+ log.warning(_("SSL certificates not found."))
+ self.https = False
if self.server in ("lighttpd", "nginx"):
log.warning(_("Sorry, we dropped support for starting %s directly within pyLoad") % self.server)
log.warning(_("You can use the threaded server which offers good performance and ssl,"))
log.warning(_("of course you can still use your existing %s with pyLoads fastcgi server") % self.server)
log.warning(_("sample configs are located in the module/web/servers directory"))
- self.server = "builtin"
-
- if self.server == "fastcgi":
+ reset = True
+ elif self.server == "fastcgi":
try:
import flup
except:
log.warning(_("Can't use %(server)s, python-flup is not installed!") % {
"server": self.server})
- self.server = "builtin"
- elif self.server == "lightweight":
- try:
- import bjoern
- except Exception, e:
- log.error(_("Error importing lightweight server: %s") % e)
- log.warning(_("You need to download and compile bjoern, https://github.com/jonashaag/bjoern"))
- log.warning(_("Copy the boern.so to module/lib folder or use setup.py install"))
- log.warning(_("Of course you need to be familiar with linux and know how to compile software"))
- self.server = "builtin"
-
- if os.name == "nt":
- self.core.log.info(_("Server set to threaded, due to known performance problems on windows."))
- self.core.config['webinterface']['server'] = "threaded"
- self.server = "threaded"
-
-
- if self.server == "fastcgi":
- self.start_fcgi()
- elif self.server == "threaded":
+ reset = True
+
+ if reset or self.server == "lightweight":
+ if os.name != "nt":
+ try:
+ import bjoern
+ except Exception, e:
+ log.error(_("Error importing lightweight server: %s") % e)
+ log.warning(_("You need to download and compile bjoern, https://github.com/jonashaag/bjoern"))
+ log.warning(_("Copy the boern.so to module/lib folder or use setup.py install"))
+ log.warning(_("Of course you need to be familiar with linux and know how to compile software"))
+ self.server = "builtin"
+ else:
+ self.core.log.info(_("Server set to threaded, due to known performance problems on windows."))
+ self.core.config['webinterface']['server'] = "threaded"
+ self.server = "threaded"
+
+ if self.server == "threaded":
self.start_threaded()
+ elif self.server == "fastcgi":
+ self.start_fcgi()
elif self.server == "lightweight":
self.start_lightweight()
else:
diff --git a/module/web/webinterface.py b/module/web/webinterface.py
index af4b9417f..21a23bbc0 100644
--- a/module/web/webinterface.py
+++ b/module/web/webinterface.py
@@ -130,7 +130,7 @@ def run_simple(host="0.0.0.0", port="8000"):
def run_lightweight(host="0.0.0.0", port="8000"):
- run(app=web, host=host, port=port, quiet=True, server="bjoern")
+ run(app=web, host=host, port=port, server="bjoern", quiet=True)
def run_threaded(host="0.0.0.0", port="8000", theads=3, cert="", key=""):