Setup development environment in VPS #8

Closed
opened 2025-10-15 07:00:20 +00:00 by juyung · 2 comments
Owner

Rsync

On VPS:

sudo chown -R user:user /var/www/app/kubeload # fixes permission denied

On local machine, create rsync.sh in project's root folder and run it:

while true; do
    rsync -avz -e "ssh -p 2222" --delete \
        --exclude 'app.db' \
        --exclude 'init.sql' \
        --exclude '__pycache__/' \
        --exclude '.venv/' \
        ./ vps@1.2.3.4:/var/www/app/kubeload

    sleep 10
done
./rsync.sh

Now I can write code locally and upload my code to server automatically.

Flask

Go to /var/www/app/kubeload. Create a virtual environment and install prerequisite packages:

python3 -m venv .venv
. .venv/bin/activate
pip install -r requirements.txt

Start the test server:

flask run # this is not intended for production server

Caddy

kubeload.com {
  redir https://www.kubeload.com{uri} 301
}

*.kubeload.com {
  encode zstd gzip

  header {
    Strict-Transport-Security "max-age=31536000; includeSubDomains; preload"
    X-Content-Type-Options "nosniff"
    X-Frame-Options "SAMEORIGIN"
    Referrer-Policy "no-referrer"
  }
}

i.kubeload.com {
  reverse_proxy localhost:8080
}

www.kubeload.com {
  reverse_proxy 127.0.0.1:5000
}
sudo systemctl restart caddy
### Rsync On VPS: ``` sudo chown -R user:user /var/www/app/kubeload # fixes permission denied ``` On local machine, create rsync.sh in project's root folder and run it: ``` while true; do rsync -avz -e "ssh -p 2222" --delete \ --exclude 'app.db' \ --exclude 'init.sql' \ --exclude '__pycache__/' \ --exclude '.venv/' \ ./ vps@1.2.3.4:/var/www/app/kubeload sleep 10 done ``` ``` ./rsync.sh ``` Now I can write code locally and upload my code to server automatically. ### Flask Go to /var/www/app/kubeload. Create a virtual environment and install prerequisite packages: ``` python3 -m venv .venv . .venv/bin/activate pip install -r requirements.txt ``` Start the test server: ``` flask run # this is not intended for production server ``` ### Caddy ``` kubeload.com { redir https://www.kubeload.com{uri} 301 } *.kubeload.com { encode zstd gzip header { Strict-Transport-Security "max-age=31536000; includeSubDomains; preload" X-Content-Type-Options "nosniff" X-Frame-Options "SAMEORIGIN" Referrer-Policy "no-referrer" } } i.kubeload.com { reverse_proxy localhost:8080 } www.kubeload.com { reverse_proxy 127.0.0.1:5000 } ``` ``` sudo systemctl restart caddy ```
juyung added this to the kubeload project 2025-10-15 07:00:20 +00:00
juyung self-assigned this 2025-10-15 07:00:27 +00:00
juyung added the due date 2025-10-15 2025-10-15 07:00:44 +00:00
Author
Owner

Development server on local machine

During development, open terminals on my local machine and run the following commands.

Start web server

. .venv/bin/activate
FLASK_APP=kubeload:app flask 

Start npm

npm run watch

Start rsync.sh

./rsync.sh
## Development server on local machine During development, open terminals on my local machine and run the following commands. Start web server ``` . .venv/bin/activate FLASK_APP=kubeload:app flask ``` Start npm ``` npm run watch ``` Start rsync.sh ``` ./rsync.sh ```
juyung changed title from Setup development environment to Setup development environment in VPS 2025-12-08 21:38:10 +00:00
Author
Owner

Production server on VPS

in VPS, enter virtual environment:

. .venv/bin/activate

Install gunicorn:

pip install gunicorn

Start production server:

nohup gunicorn -w 9 -b 127.0.0.1:8111 kubeload:app > kubeload.log 2>&1 &

Check server:

ps aux | grep gunicorn
## Production server on VPS in VPS, enter virtual environment: ``` . .venv/bin/activate ``` Install gunicorn: ``` pip install gunicorn ``` Start production server: ``` nohup gunicorn -w 9 -b 127.0.0.1:8111 kubeload:app > kubeload.log 2>&1 & ``` Check server: ``` ps aux | grep gunicorn ```
Sign in to join this conversation.
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

2025-10-15

Dependencies

No dependencies set.

Reference: juyung/kubeload#8
No description provided.