3.7 KiB
Marietje
Welcome to the repository of Marietje! Marietje is the system that provides music in the South canteen of the Huygens building. Students of the faculty of science can request an account at the administrators and then upload and queue music.
Getting started
This project is built using the Django framework. Poetry is used for dependency management.
Development setup
- Get at least Python 3.9 installed on your system.
- Clone this repository.
- If
pip3is not installed on your system yet, executeapt install python3-pipon your system. - Also make sure
python3-devis installed on your system, executeapt install python3-dev. - Install Poetry by following the steps on their website. Make sure
poetry is added to
PATHbefore continuing. - Make sure
poetryuses your python 3 installation:poetry env use python3. - Run
poetry installto install all dependencies. - Run
poetry shellto start a shell with the dependencies loaded. This command needs to be run every time you open a new shell and want to run the development server. - Run
cd marietjeto change directories to thewebsitefolder containing the project. - Change the
DATABASESsetting inmarietje/marietje/settings/settings.pyto the following:
"default": {
"ENGINE": "django.db.backends.sqlite3",
"NAME": os.path.join(BASE_DIR, "db.sqlite3"),
}
- Install berthad on your system by following the README file. berthad is used for storing the music files.
- Start a bertad service by following the berthad README file.
- Adjust the
BERTHA_HOSTsetting inmarietje/marietje/settings/settings.pyto the host you created previously. - Run
./manage.py migrateto initialise the database and run all migrations. - Run
./manage.py createsuperuserto create an administrator that is able to access the backend interface later on. - Run
./manage.py runserverto start the development server locally.
Optionally you can enable debug mode by changing the boolean setting DEBUG in marietje/marietje/setting/settings.py
to TRUE.
Production setup
For a production environment, the steps for the development setup can be followed up until running the actual server. In a production environment, usage of uWSGI is recommended, so this needs to be installed. Then, using the snippet below, a service file can be used to start the uWSGI in the Poetry environment.
[Unit]
Description=MarietjeDjango website
After=syslog.target
[Service]
ExecStart=poetry run uwsgi \
--socket /run/uwsgi/MarietjeDjango.socket \
--uid=www-data \
--gid=www-data \
--module=marietje.wsgi \
--workers 2 --master \
--disable-write-exception
WorkingDirectory=/srv/MarietjeDjango/marietje
Restart=always
KillSignal=SIGQUIT
Type=notify
StandardError=syslog
NotifyAccess=all
ProtectSystem=full
ProtectHome=yes
RuntimeDirectory=uwsgi
PrivateTmp=no
PrivateDevices=yes
ProtectControlGroups=yes
RemoveIPC=yes
[Install]
WantedBy=multi-user.target
The current production environment uses Nginx as webserver that connects to this WSGI socket.
Static files are served from marietje/static.
They can be loaded using ./manage.py collectstatic.
A minimal Nginx configuration for both IPv4 and IPv6 as default would be the following.
server {
listen 80 default_server;
listen [::]:80 default_server;
location /static {
alias /srv/MarietjeDjango/marietje/static;
}
location / {
uwsgi_pass unix:///run/uwsgi/MarietjeDjango.service;
include uwsgi_params;
}
}