Setting up the server - CosmosTUe/Cosmos GitHub Wiki
Instructions to prepare website
1. Create new user to run the website as
sudo adduser cosmos --disabled-password --home /opt/cosmos
local-dev wiki
1. Please refer to section 1 of thecosmos
user
Run steps 1.3 - 1.6 as the sudo -iu cosmos
When using pipenv to install the dependencies use
pipenv install --deploy
this will ensure that dependencies from the lock file are used
2. Enable server-specific apps
Change 'supervised no' to 'supervised systemd' in /etc/redis/redis.conf
.
sudo systemctl enable --now redis-server.service
Make sure the cosmos user is able to access the directories it needs
sudo mkdir /var/run/celery
sudo mkdir /var/log/celery
sudo chown cosmos:cosmos /var/run/celery
sudo chown cosmos:cosmos /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 manage.py migrate
Create an admin user
python manage.py createsuperuser
Collect all the static files for nginx
python manage.py collectstatic
Check if setting up the database worked
python manage.py runserver 0.0.0.0:8000
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 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
Finally, enable and start the server
sudo systemctl --now enable gunicorn.socket
Tips for Max
don't forget to reload nginx AND gunicorn