From 7c593f2fc221dd2862e43954fee911ae6d2bea3a Mon Sep 17 00:00:00 2001 From: Raymaekers Luca Date: Tue, 4 Apr 2023 18:46:26 +0200 Subject: [PATCH 1/3] renamed venv to env --- .gitignore | 2 +- README.md | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.gitignore b/.gitignore index 4822f1c..0266622 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,3 @@ __pycache__ upload -venv +env diff --git a/README.md b/README.md index 134d08b..a4a48a7 100644 --- a/README.md +++ b/README.md @@ -23,9 +23,9 @@ cd git clone https://code.cronyakatsuki.xyz/crony/upfast . # Create the virtual environment and load it for user on default -python3 -m venv venv +python3 -m venv env # Activate the virtual environment -source venv/bin/activate +source env/bin/activate # Install all the requirements pip install -r requirements.txt @@ -52,7 +52,7 @@ Documentation=https://code.cronyakatsuki.xyz/crony/upfast User=upfast Group=upfast WorkingDirectory=/usr/local/upfast/ -ExecStart=/usr/local/upfast/venv/bin/uvicorn main:app --host 127.0.0.1 --port 8000 --proxy-headers --forwarded-allow-ips='*' +ExecStart=/usr/local/upfast/env/bin/uvicorn main:app --host 127.0.0.1 --port 8000 --proxy-headers --forwarded-allow-ips='*' Restart=on-failure ``` Finally run following commmands. From da70b22fdfbe88aace087dd3ddf39dd680b82f6a Mon Sep 17 00:00:00 2001 From: Raymaekers Luca Date: Tue, 4 Apr 2023 18:47:37 +0200 Subject: [PATCH 2/3] added upfast.sh for quick install and upfast.service --- upfast.service | 10 ++++++++++ upfast.sh | 27 +++++++++++++++++++++++++++ 2 files changed, 37 insertions(+) create mode 100644 upfast.service create mode 100755 upfast.sh diff --git a/upfast.service b/upfast.service new file mode 100644 index 0000000..c2843d1 --- /dev/null +++ b/upfast.service @@ -0,0 +1,10 @@ +[Unit] +Description=UpFast service +Documentation=https://code.cronyakatsuki.xyz/crony/upfast + +[Service] +User=upfast +Group=upfast +WorkingDirectory=/usr/local/upfast/ +ExecStart=/usr/local/upfast/env/bin/uvicorn main:app --host 127.0.0.1 --port 8000 --proxy-headers --forwarded-allow-ips='*' +Restart=on-failure diff --git a/upfast.sh b/upfast.sh new file mode 100755 index 0000000..f1838f0 --- /dev/null +++ b/upfast.sh @@ -0,0 +1,27 @@ +#!/bin/sh + +# quick install (and run) script for upfast using systemd +if [ $EUID -ne 0] +then + echo "Please run as root" + exit 1 +fi + +cp ./upfast.service /etc/systemd/system/upfast.service + +useradd --shell /bin/sh --system --home-dir /usr/local/upfast upfast +mkdir -p /usr/local/upfast # dodge copying of skeletons + +chown upfast:upfast /usr/local/upfast +chmod 700 /usr/local/upfast + +su upfast -c' +cd +git clone https://git.craftmenners.men/upfast . + +python3 -m venv env +. ./env/bin/activate +pip install -r requirements.txt +mkdir upload' + +systemctl enable --now upfast.service From b376d91e21805a000c6ad242a501f47908729e5b Mon Sep 17 00:00:00 2001 From: Raymaekers Luca Date: Tue, 4 Apr 2023 18:52:14 +0200 Subject: [PATCH 3/3] extracted nginx conf into file --- upfast-nginx | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 upfast-nginx diff --git a/upfast-nginx b/upfast-nginx new file mode 100644 index 0000000..0494af8 --- /dev/null +++ b/upfast-nginx @@ -0,0 +1,15 @@ +server { + listen 80; + listen [::]:80; + + server_name upfast.example.com ; + + location / { + proxy_pass http://127.0.0.1:8000; + proxy_set_header Host $host; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + proxy_redirect off; + proxy_buffering off; + } +}