Setting up the server - CosmosTUe/Cosmos Wiki

Instructions to prepare website

1. Please refer to section 1 of the local-dev wiki

2. Install and enable server-specific apps

sudo apt-get install rabbitmq-server
sudo systemctl enable --now rabbitmq-server.service 

Create a new user for celery with

sudo useradd celery

TODO:Verify if this is necessary

Make sure the celery user is able to access the directories it needs

sudo mkdir /var/run/celery
sudo mkdir /var/log/celery
sudo chown celery:celery /var/run/celery
sudo chown celery:celery /var/log/celery

then copy the systemd file from the server repo and enable the service

cp celery.service /etc/systemd/system/celery.service
cp celeryd /etc/conf.d/celery
sudo systemctl enable --now celery.service

3. Finalize website

Copy the secrets file from server/secrets.json to /etc/secrets.json, and fill in the credentials. Make sure they are kept secret and are different from the default credentials in the file.

Create and apply migrations to the database, this sets up the initial database structure.

python migrate

Create an admin user

python createsuperuser

Collect all the static files for nginx

python migrate

Check if setting up the database worked

python runserver

Instructions to make website accessible

4. Copy all the server specific files to their respective directories

Copy the systemd service and socket and reload the services

sudo cp server/gunicorn.* /etc/systemd/system/
sudo systemctl daemon-reload

Copy sudoers file to give the automatic deployment user permission to run the service

sudo cp server/deployerperm /etc/sudoers.d/

Copy and symlink the Nginx config file and then enable and start it

sudo cp server/nginx-cosmosweb /etc/nginx/sites-available/
sudo ln -s /etc/nginx/sites-available/nginx-cosmosweb /etc/nginx/sites-enabled
sudo systemctl --now enable nginx

Copy the shell script that is used for automated git deployment

cp server/ ..

Finally, enable and start the server

sudo systemctl --now enable gunicorn.socket

Tips for Max

don't forget to reload nginx AND gunicorn