Compare commits
12 Commits
422baeaae2
...
5c6448f96a
Author | SHA1 | Date | |
---|---|---|---|
5c6448f96a | |||
b407949d0a | |||
|
e9563be67a | ||
|
3d1ba3bb5c | ||
|
17c172a73d | ||
|
76963bcd88 | ||
|
1987a3fbef | ||
|
fb7b89a101 | ||
|
972f55f38d | ||
|
b376d91e21 | ||
|
da70b22fdf | ||
|
7c593f2fc2 |
2
.gitignore
vendored
2
.gitignore
vendored
@ -1,3 +1,3 @@
|
|||||||
__pycache__
|
__pycache__
|
||||||
upload
|
upload
|
||||||
venv
|
env
|
||||||
|
77
README.md
77
README.md
@ -10,57 +10,20 @@ To run on a regular system I recommend to use a virtual environment to install t
|
|||||||
|
|
||||||
We will also be setting up an specific user to run the app as safe as possible with a systemd service file for startup
|
We will also be setting up an specific user to run the app as safe as possible with a systemd service file for startup
|
||||||
|
|
||||||
|
#### Installing
|
||||||
```bash
|
```bash
|
||||||
# Create the user (You can specify a different home-dir)
|
./install.sh
|
||||||
sudo useradd --shell /bin/bash --system \
|
|
||||||
--home-dir "/usr/local/upfast" -m upfast
|
|
||||||
|
|
||||||
# Change to upfast user and go to upfast dir
|
|
||||||
su upfast
|
|
||||||
cd
|
|
||||||
|
|
||||||
# Clone the project directly into upfast-src directory
|
|
||||||
git clone https://code.cronyakatsuki.xyz/crony/upfast .
|
|
||||||
|
|
||||||
# Create the virtual environment and load it for user on default
|
|
||||||
python3 -m venv venv
|
|
||||||
# Activate the virtual environment
|
|
||||||
source venv/bin/activate
|
|
||||||
# Install all the requirements
|
|
||||||
pip install -r requirements.txt
|
|
||||||
|
|
||||||
# create the upload directory
|
|
||||||
mkdir upload
|
|
||||||
|
|
||||||
# UpFast go brrr
|
|
||||||
uvicorn main:app --host 127.0.0.1 --port 8000 --proxy-headers --forwarded-allow-ips='*'
|
|
||||||
```
|
```
|
||||||
|
|
||||||
#### Autostart with systemd
|
#### Running
|
||||||
|
|
||||||
To autostart with systemd you will need to create a systemd .service file in path `/etc/systemd/system/upfast.service` and add this content to it.
|
|
||||||
|
|
||||||
```systemd
|
|
||||||
[Unit]
|
|
||||||
Description=UpFast service
|
|
||||||
Documentation=https://code.cronyakatsuki.xyz/crony/upfast
|
|
||||||
|
|
||||||
[Service]
|
|
||||||
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='*'
|
|
||||||
Restart=on-failure
|
|
||||||
```
|
|
||||||
Finally run following commmands.
|
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
# refresh services
|
systemctl start upfast.service
|
||||||
sudo systemctl daemon-reload
|
|
||||||
# enable the service
|
|
||||||
sudo systemctl enable upfast.service
|
|
||||||
```
|
```
|
||||||
|
|
||||||
|
#### Start on boot
|
||||||
|
```bash
|
||||||
|
systemctl enable upfast.service
|
||||||
|
```
|
||||||
### Docker
|
### Docker
|
||||||
|
|
||||||
In the repo there is an included dockerfile to generate an image from the latest version of everything, to generate an image just run `docker build . -t upfast` (You need root privileges or to be in the docker group).
|
In the repo there is an included dockerfile to generate an image from the latest version of everything, to generate an image just run `docker build . -t upfast` (You need root privileges or to be in the docker group).
|
||||||
@ -77,24 +40,14 @@ The sample command will need an upload directory, you can replace `./upload` wit
|
|||||||
### Nginx Proxy setup
|
### Nginx Proxy setup
|
||||||
|
|
||||||
This is an example nginx proxy config for http
|
This is an example nginx proxy config for http
|
||||||
|
```bash
|
||||||
|
cp ./upfast-nginx /etc/nginx/sites-available/upfast
|
||||||
|
ln -sf /etc/nginx/sites-available/upfast /etc/nginx/sites-enabled/
|
||||||
|
```
|
||||||
|
|
||||||
```nginx
|
> Load config
|
||||||
server {
|
```bash
|
||||||
|
systemctl reload nginx
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
```
|
```
|
||||||
|
|
||||||
# Contributions
|
# Contributions
|
||||||
|
26
install.sh
Executable file
26
install.sh
Executable file
@ -0,0 +1,26 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
# quick install (and run) script for upfast using systemd
|
||||||
|
if [ $EUID -ne 0]
|
||||||
|
then
|
||||||
|
echo "Please run as root"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
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://code.cronyakatsuki.xyz/crony/upfast .
|
||||||
|
|
||||||
|
python3 -m venv env
|
||||||
|
. ./env/bin/activate
|
||||||
|
pip install -r requirements.txt
|
||||||
|
mkdir upload'
|
||||||
|
|
||||||
|
cp ./upfast.service /etc/systemd/system/upfast.service
|
||||||
|
systemctl daemon-reload
|
15
upfast-nginx
Normal file
15
upfast-nginx
Normal file
@ -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;
|
||||||
|
}
|
||||||
|
}
|
13
upfast.service
Normal file
13
upfast.service
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
[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
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=multi-user.target
|
Loading…
Reference in New Issue
Block a user