-
Notifications
You must be signed in to change notification settings - Fork 3
Setting up the server
sudo adduser cosmos --disabled-password --home /opt/cosmos
1. Please refer to section 1 of the local-dev wiki
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
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
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
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
don't forget to reload nginx AND gunicorn