From cb81b44a27e774d306ef744f79d81f2169a99e06 Mon Sep 17 00:00:00 2001 From: makefu Date: Tue, 19 Nov 2013 09:44:44 +0100 Subject: [PATCH 1/2] remove distribute from deps --- bump/static/favicon.ico | Bin 0 -> 1150 bytes deps.txt | 1 - 2 files changed, 1 deletion(-) create mode 100644 bump/static/favicon.ico diff --git a/bump/static/favicon.ico b/bump/static/favicon.ico new file mode 100644 index 0000000000000000000000000000000000000000..d8f67e7aec6d3061c9da7c411c975aaea20f998e GIT binary patch literal 1150 zcmd6kF$w}f3`L)4C!!#TrKO-Z@IoF&EWCrIcm>a3wOCnLTZ@e*4j;lWvsyY!_9rj@ z&k91vp3w+<&sg_h0?e%p8A;p(Y&Y(w`pkdyT5x;$&vA{tm^9xx_ah#Av0S6adq48T zUM$z>@m@#1I6EtGd7{eui^g2ux8-xM=C(|2r>v`cG}rvOr{pg&-B;Q<(>~rW9y76z z8RewPYL>Ugqc8tPEhAo1-BHuh_iEm6{AK@|*Le?@L#q1 Date: Tue, 19 Nov 2013 10:10:04 +0100 Subject: [PATCH 2/2] add configuration for nginx/supervisor, add run.sh --- Readme.md | 7 +++---- bump/init.py | 8 +++----- etc/bump.nginx.conf | 14 ++++++++++++++ etc/bump.supervisor.conf | 5 +++++ run.sh | 5 +++++ 5 files changed, 30 insertions(+), 9 deletions(-) create mode 100644 etc/bump.nginx.conf create mode 100644 etc/bump.supervisor.conf create mode 100755 run.sh diff --git a/Readme.md b/Readme.md index f606be6..c9d7ff7 100644 --- a/Readme.md +++ b/Readme.md @@ -11,7 +11,6 @@ It is written as a replacement for the gorgeous sprunge.us pip install -r deps.txt ## Startup - - . bin/activate - cd bump - gunicorn -b 127.0.0.1:4000 init:app + + + ./run.sh diff --git a/bump/init.py b/bump/init.py index bfdaa10..7ca01d2 100644 --- a/bump/init.py +++ b/bump/init.py @@ -6,6 +6,9 @@ import os app = Flask(__name__) storedir = os.path.join(app.root_path, 'store') app.config['storedir'] = storedir +print("Storedir is %s" % storedir) +if not os.path.isdir(storedir): + os.mkdir(storedir) def returns_plain(f): @@ -84,9 +87,4 @@ def generate_key(): if __name__ == "__main__": app.debug = True - print("Storedir is %s" % storedir) - try: - os.mkdir(storedir) - except: - pass app.run(host='0.0.0.0') diff --git a/etc/bump.nginx.conf b/etc/bump.nginx.conf new file mode 100644 index 0000000..87429c9 --- /dev/null +++ b/etc/bump.nginx.conf @@ -0,0 +1,14 @@ +server { + listen [::]:80; + server_name _; + access_log /var/log/nginx/log/note.log main; + error_log /var/log/nginx/log/note_error.log; + default_type text/plain; + location / { + proxy_pass http://127.0.0.1:4000/; + proxy_redirect off; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + } +} diff --git a/etc/bump.supervisor.conf b/etc/bump.supervisor.conf new file mode 100644 index 0000000..078f20c --- /dev/null +++ b/etc/bump.supervisor.conf @@ -0,0 +1,5 @@ +[program:bump] +command=sh run.sh +user=note +directory=/opt/bump +autorestart=true diff --git a/run.sh b/run.sh new file mode 100755 index 0000000..205796d --- /dev/null +++ b/run.sh @@ -0,0 +1,5 @@ +#!/bin/sh +set -ef +. bin/activate +cd bump +gunicorn -b 127.0.0.1:4000 init:app