Skip to content

Commit

Permalink
Deploy stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
anze3db committed Sep 15, 2024
1 parent 79a3eb6 commit 5b0fb4b
Show file tree
Hide file tree
Showing 6 changed files with 60 additions and 1 deletion.
26 changes: 26 additions & 0 deletions .deploy/nginx.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
server {
client_max_body_size 4M;

server_name surfcams.pecar.me;

location / {
proxy_set_header Host $http_host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
proxy_redirect off;
proxy_buffering off;
proxy_pass http://surfcams;
}

}

map $http_upgrade $connection_upgrade {
default upgrade;
'' close;
}

upstream surfcams {
server unix:///home/anze/projects/surfcams/gunicorn.sock;
}
5 changes: 5 additions & 0 deletions .deploy/run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/bash
set -e
pushd "$(dirname "$0")/.."
uv run gunicorn surfcamsapi.asgi:application
popd
12 changes: 12 additions & 0 deletions .deploy/surfcams.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[Unit]
Description=Surfcams
After=nginx.service

[Service]
Type=simple
Restart=always
RestartSec=1
ExecStart=/bin/bash /home/anze/projects/surfcams/.deploy/run.sh

[Install]
WantedBy=multi-user.target
10 changes: 10 additions & 0 deletions .deploy/update.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/bash
set -e
pushd "$(dirname "$0")/.."
git pull
uv sync --frozen
uv run python manage.py collectstatic --noinput
uv run python manage.py migrate
sudo kill -hup `cat gunicorn.pid`
echo `date "+%Y-%m-%d %H:%M:%S.%3N"` ' Updated' >> update.log
popd
2 changes: 1 addition & 1 deletion .github/workflows/python.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,5 +37,5 @@ jobs:
# key: ${{ secrets.SSH_KEY }}
# port: ${{ secrets.SSH_PORT }}
# script: |
# bash projects/surfcamsapi/.deploy/update.sh
# bash projects/surfcams/.deploy/update.sh

6 changes: 6 additions & 0 deletions gunicorn.conf.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
bind = "unix:gunicorn.sock"
workers = 1
threads = 4
proc_name = "surfcams"
worker_class = "uvicorn.workers.UvicornWorker"
pidfile = "gunicorn.pid"

0 comments on commit 5b0fb4b

Please sign in to comment.