Skip to content

Source code for the AIRPACT-Fire project's website. Provides the API's for both the Android and iOS clients.

Notifications You must be signed in to change notification settings

vizinet/backend

 
 

Repository files navigation

TODO

  • Fix issue with CAPTCHA v3 (as of Novemeber 3rd).
  • Fix issue with user registration saying username or email already exists (when it doesn't?).

Developing Locally

Restore development environment for Python 2.7 on Ubuntu:

pip2 install -r requirements.txt

This will install all the same packages we used to develop the website and backend.

How We Run

Gunicorn runs on the server at localhost:8080 with Nginx on top as a reverse-proxy, handling everything from port 80 (HTTP traffic).

The config for the Nginx server can be found in /etc/nginx/nginx.conf and the service config for Gunicorn can be found under /etc/systemd/system/gunicorn.service.

Our SSL certificates are obtained using Let's Encrypt are are auto-renewed every 90 days using a CRON job. This checks twice daily, and it's suggested to pick a random minute within the scheduled hour to renew on:

0 0,12 * * * python -c 'import random; import time; time.sleep(random.random() * 3600)' && ./path/to/certbot-auto renew 

Getting Started

Step 1: SSH into the thing!

sudo ssh [email protected] # Password: airpact@fire#16

Step 2: Run server

cd /home/admin/Website

No Logs

sudo gunicorn --bind 0.0.0.0:80 AIRPACT_Fire.wsgi:application # In the same directory as `manage.py`

Log to master_log file

sudo gunicorn --bind 0.0.0.0:80 --log-level debug --log-file master_log AIRPACT_Fire.wsgi:application

Updating Server Code

After you've committed your changes locally and pushed them to this repository under the master branch, do the following.

Step 1: Stop server

Kill the server with

ps -A # Find the process with the Gunicorn pid
sudo kill [pid] # Kill that process

Step 3: Pull down changes

Now move to the website directory with

cd /home/admin/Website

and then pull your changes down from GitHub via

git pull

Step 3: Restart server

At last you can start the server again

sudo gunicorn --bind 0.0.0.0:80 AIRPACT_Fire.wsgi:application

Restarting Server

Run through the Updating Server Code section, but skip step 3.

Log Script

Usage:

sudo ./log_script [log_file] [url_to_post]

or with nohup (so script doesn't die when server is off):

sudo nohup ./log_script [file] [url] &

Example:

sudo nohup ./log_script master_log https://hooks.slack.com/services/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 &

Git

git clone https://github.com/AIRPACT-Fire/Website.git

About

Source code for the AIRPACT-Fire project's website. Provides the API's for both the Android and iOS clients.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • HTML 52.0%
  • Python 44.0%
  • CSS 3.6%
  • Shell 0.4%