Skip to content

Server Basics

Siqi Tian edited this page Feb 5, 2017 · 7 revisions

The server runs on linux(Ubuntu) instance at AWS. Information about AWS is in config/oauth.conf under AWS.

Apache is the reverse proxy that sits between Django (the app) and outside world. It handles HTTP requests and spawns python processes. Django is used for web framework. MySQL is the database engine.

When making changes to static assets, including *.html, *.css, *.js, images/pdf files, as well as MySQL database, you don't need to restart Apache. Changes will be reflected upon browser refresh (sometimes browser cache may delay it).

In contrary, when making changes to script files, including *.py, *.conf, *.sh, as well as Apache settings, you have to restart Apache to reflect changes. A quick way to do so is running a2rs, which is an alias for sudo apache2ctl restart.

In addition, changes to the primerize package requires reinstalling of primerize and Apache restart. To do so, run cd ~/NA_Thermo && sudo -H python setup.py install.

Server Downtime

To mark the server as temporarily unavailable, change IS_MAINTENANCE to true in config/t47_dev.py. The server will still be running, but only returns status 503 for any requests.

Shortcut Commands

The following aliases are provided for you convenience:

  • sync: Updates server code from repository, makes it ready, and deploys.
  • upd: Updates installed packages.
  • Other commands for checking logs, cron jobs, and swap memory. See /admin/ref/ for more details.

Django Commands

The following Django commands are available. Run them with dj_man, or in full-length, e.g. python manage.py dist.

Command Description
backup Backs up static files, MySQL, Apache, and local config/ files into backup/ folder.
cleanup Removes data/ files and JOB_ID from MySQL for jobs that are older than KEEP_JOB in config/cron.conf.
dist Downloads primerize package releases and master into dist/, and updates cache/stat_dist.json.
gdrive Uploads most recent backup onto daslab Google Drive and cleans up obsolete backup files.
restore Restores static files, MySQL, Apache, and local config/ files from local backup/ files.
versions Collects system installed package versions into cache/stat_sys.json and cache/stat_ver.json.

Environment Path

Item Path
Repository /home/ubuntu/Server_Primerize/
MySQL settings /etc/mysql/my.cnf
Apache settings /etc/apache2/
Apache log /var/log/apache2/
Django and cron log cache/
static files data/
primerize package distribution dist/
primerize installation /home/admin/NA_Thermo/
Secret / configurations config/

Clone this wiki locally