Skip to content
Snippets Groups Projects
Commit 5f5b094f authored by Rolf Niepraschk's avatar Rolf Niepraschk
Browse files

Parameterübergabe angepasst

parent 9c2f079c
No related branches found
No related tags found
No related merge requests found
#!/bin/bash #!/bin/bash
# $1 = flask port # $1 = flask port (required)
# $2 = data path # $2 = data path (required)
# $3 = flask env (optional: development or production, default: development)
# $4 = flask debug (optional: 0 or 1, default: 1)
if [ $# -lt 2 ]; then if [ $# -lt 2 ]; then
echo "error: missing parameter" echo "error: at least two parameters are expected"
exit -1 exit -1
fi fi
export FLASK_RUN_PORT="$1" FLASK_RUN_PORT={$1}
export FLASK_APP=server.py DATA_PATH={$2}
export FLASK_DEBUG=1 FLASK_ENV=${3:-development}
export FLASK_ENV=development # TODO: FLASK_ENV=production FLASK_DEBUG=${4:-1}
python3 -m venv ./ python3 -m venv ./
source bin/activate source bin/activate
pip3 install -e . pip3 install -e ./
python3 server.py "$2"
python3 server.py "$1" "$2" "$3" "$4"
...@@ -4,9 +4,12 @@ from flask_cors import CORS ...@@ -4,9 +4,12 @@ from flask_cors import CORS
from urllib.parse import urlparse from urllib.parse import urlparse
import sys, requests import sys, requests
app = Flask(__name__) app = Flask(__name__)
DATA_PATH = sys.argv[1] FLASK_RUN_PORT = sys.argv[1]
DATA_PATH = sys.argv[2]
FLASK_ENV = sys.argv[3]
FLASK_DEBUG = sys.argv[4]
COUCHDB_PROTO = 'http' COUCHDB_PROTO = 'http'
COUCHDB_PORT = '5984' COUCHDB_PORT = '5984'
DB = 'vl_db' DB = 'vl_db'
...@@ -81,4 +84,6 @@ def couchdb_proxy(p=''): ...@@ -81,4 +84,6 @@ def couchdb_proxy(p=''):
return response return response
if __name__ == '__main__': if __name__ == '__main__':
app.run(host='0.0.0.0') app.config["ENV"] = FLASK_ENV
app.config["DEBUG"] = FLASK_DEBUG
app.run(host='0.0.0.0', port=FLASK_RUN_PORT)
...@@ -6,12 +6,15 @@ After=network.target ...@@ -6,12 +6,15 @@ After=network.target
User=nobody User=nobody
Environment=FLASK_PORT=8081 Environment=FLASK_PORT=8081
Environment=DATA_PATH=/srv/www/data/ Environment=DATA_PATH=/srv/www/data/
Environment=FLASK_ENV=production
Environment=FLASK_DEBUG=1
Type=simple Type=simple
StandardOutput=null StandardOutput=null
StandardError=null StandardError=null
Restart=no Restart=no
WorkingDirectory=/usr/local/share/webapps-deliverer WorkingDirectory=/usr/local/share/webapps-deliverer
ExecStart=/bin/bash -l -c "source bin/activate;./server ${FLASK_PORT} ${DATA_PATH}" ExecStart=/bin/bash -l -c "source bin/activate;./server \
${FLASK_PORT} ${DATA_PATH} ${FLASK_ENV} ${FLASK_DEBUG}"
[Install] [Install]
WantedBy=multi-user.target WantedBy=multi-user.target
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment