1
0
forked from crony/UpFast

Compare commits

...

6 Commits

Author SHA1 Message Date
Raymaekers Luca
69f19a1888 Merge branch 'installation' into mine 2023-04-05 13:01:12 +02:00
Raymaekers Luca
17c172a73d added loading for the nginx config 2023-04-05 12:59:48 +02:00
Raymaekers Luca
76963bcd88 removed the files' content from readme 2023-04-05 12:55:15 +02:00
Raymaekers Luca
1987a3fbef added install section to service 2023-04-05 12:54:52 +02:00
Raymaekers Luca
fb7b89a101 added daemon reload to install script 2023-04-05 12:54:38 +02:00
Raymaekers Luca
972f55f38d renamed upfast.sh to install.sh 2023-04-05 12:48:30 +02:00
3 changed files with 20 additions and 68 deletions

View File

@ -10,60 +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
#### Installing
```bash
# Create the user (You can specify a different home-dir)
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 env
# Activate the virtual environment
source env/bin/activate
# Install all the requirements
pip install -r requirements.txt
# Load environment by default
echo "source /usr/local/upfast/venv/bin/activate" > "/usr/local/upfast/.profile"
# create the upload directory
mkdir upload
# UpFast go brrr
uvicorn main:app --host 127.0.0.1 --port 8000 --proxy-headers --forwarded-allow-ips='*'
./install.sh
```
#### Autostart with systemd
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/env/bin/uvicorn main:app --host 127.0.0.1 --port 8000 --proxy-headers --forwarded-allow-ips='*'
Restart=on-failure
```
Finally run following commmands.
#### Running
```bash
# refresh services
sudo systemctl daemon-reload
# enable the service
sudo systemctl enable upfast.service
systemctl start upfast.service
```
#### Start on boot
```bash
systemctl enable upfast.service
```
### 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).
@ -80,24 +40,14 @@ The sample command will need an upload directory, you can replace `./upload` wit
### Nginx Proxy setup
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
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;
}
}
> Load config
```bash
systemctl reload nginx
```
# Contributions

View File

@ -7,8 +7,6 @@ then
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
@ -24,4 +22,5 @@ python3 -m venv env
pip install -r requirements.txt
mkdir upload'
systemctl enable --now upfast.service
cp ./upfast.service /etc/systemd/system/upfast.service
systemctl daemon reload

View File

@ -8,3 +8,6 @@ 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