diff options
| author | yo mama <pepper@scannerjammer.com> | 2016-08-23 15:03:36 -0700 |
|---|---|---|
| committer | yo mama <pepper@scannerjammer.com> | 2016-08-23 15:03:36 -0700 |
| commit | 66acdc91221cecb8bd3c00787ab0ec71402a1621 (patch) | |
| tree | b7ba932c4eb3ba4a55ff80b3142eb52763d3871c | |
| parent | 944e5c21adecd2b57af76d76854f4acfabf74402 (diff) | |
fixed grid script
| -rwxr-xr-x | bin/grid | 7 | ||||
| -rw-r--r-- | photoblaster/server.py | 39 | ||||
| -rw-r--r-- | run_server.py | 2 |
3 files changed, 45 insertions, 3 deletions
@@ -237,5 +237,10 @@ if [ $xinc -le $width ] fi # process image -convert $tmpA -fill none -stroke $color -strokewidth $thickness -draw "stroke-opacity $opacity path '$drawstr'" $outfile +opacity_setting="stroke-opacity $opacity" +if [ "$opacity" -eq 1 ]; then + opacity_setting=""; + +fi +convert $tmpA -fill none -stroke $color -strokewidth $thickness -draw "$opacity_setting path '$drawstr'" $outfile exit 0 diff --git a/photoblaster/server.py b/photoblaster/server.py index 1b98ad0..b553a99 100644 --- a/photoblaster/server.py +++ b/photoblaster/server.py @@ -1,3 +1,4 @@ +from __future__ import unicode_literals """All webserver logic lives here, including routes""" from flask import Flask, Response from flask import request, jsonify, render_template, send_from_directory @@ -15,6 +16,11 @@ from photoblaster.param import BadParamError, FileTooBigError from photoblaster.config import SERVER_HOST, SERVER_PORT, STATIC_FOLDER, \ WORKING_DIR, LOCAL, GALLERY_LIMIT +import multiprocessing +import gunicorn.app.base +from gunicorn.six import iteritems + + # gallery stuff GALLERY_TAG_TRANS = { "grid": "PbGrid", @@ -60,6 +66,27 @@ _CLASSNAME_ALIASES = { } +class GunicornServer(gunicorn.app.base.BaseApplication): + def __init__(self, app, host, port): + self.options = { + 'bind': '%s:%s' % (host, port), + 'workers': (multiprocessing.cpu_count() * 2) + 1, + 'loglevel': 'debug' + } + self.application = app + self.application.config['DEBUG'] = True + super(GunicornServer, self).__init__() + + def load_config(self): + config = dict([(key, value) for key, value in iteritems(self.options) + if key in self.cfg.settings and value is not None]) + for key, value in iteritems(config): + self.cfg.set(key.lower(), value) + + def load(self): + return self.application + + class InvalidUsage(Exception): """error class for InvalidUsage""" status_code = 400 @@ -269,7 +296,17 @@ class Server(object): raise e def run(self, host=SERVER_HOST, port=SERVER_PORT, **kwargs): - self.app.run(host=host, port=port, debug=True, **kwargs) + gunicorn_server = GunicornServer( + self.app, + port=port, + host=host + ) + gunicorn_server.run() +# self.app.run( +# host=host, port=port, debug=True +# processes=4 +# #**kwargs +# ) def run_wsgi(self, server_port=SERVER_PORT, host=SERVER_HOST): # http://fgimian.github.io/blog/2012/12/08/setting-up-a-rock-solid-python-development-web-server/ diff --git a/run_server.py b/run_server.py index 32c714b..a380241 100644 --- a/run_server.py +++ b/run_server.py @@ -24,6 +24,6 @@ if __name__ == "__main__": "ERROR:\n" "you must start nginx to serve static content\n") sys.exit(1) - server.run(threaded=True) + server.run(threaded=True, processes=4) else: server.run_wsgi() |
