From 3f1714ab7d71add35ae544e5b6f1ba600ba2efa4 Mon Sep 17 00:00:00 2001 From: makefu Date: Tue, 19 Nov 2013 10:10:04 +0100 Subject: [PATCH] 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