# AMT James Billings ## Infrastructure ### FastAPI - Handles HIT acceptance - Handles interface b/w react and backend: work, preview, report. - Handling of submitted assignments: - mturk_notifications view: SNS will POST to this endpoint whenever a user submits an assignment - The message gets added to our event stream - process_mturk_events (which calls process_assignment_submitted) ### React ### AirFlow - Refill Hits, check for expired hits ## Network ## System Environment ### Debian 12 #### Update & Install required system requirements ```shell apt-get update apt-get upgrade apt install -y build-essential libssl-dev zlib1g-dev libbz2-dev \ libreadline-dev libsqlite3-dev wget curl llvm libncurses5-dev libncursesw5-dev \ xz-utils tk-dev libffi-dev liblzma-dev python3-openssl git supervisor python3-dev \ libmemcached-dev libpq-dev htop supervisor rsync wget https://www.python.org/ftp/python/3.13.7/Python-3.13.7.tgz tar -xf Python-3.13.7.tgz cd Python-3.13.7 ./configure --enable-optimizations make -j 4 make altinstall python3.13 --version python3.13 -m venv /root/amt-jb-venv ``` #### Git pull projects ```shell cd ~ git clone ssh://code.g-r-l.com/panels/amt-jb cd amt-jb source /root/amt-jb-venv/bin/activate pip install -U pip setuptools wheel pip install -r requirements.txt ``` #### Supervisor ```shell cd /etc/supervisor/conf.d/ ln -s /root/amt-jb/amt-jb.conf . supervisorctl reread supervisorctl reload ``` #### Database ```shell apt install -y postgresql-common bash /usr/share/postgresql-common/pgdg/apt.postgresql.org.sh apt update apt-cache policy postgresql apt install postgresql -y systemctl enable postgresql systemctl start postgresql systemctl status postgresql vim /etc/postgresql/18/main/pg_hba.conf ``` #### Setup DNS Cache (LXC) ``` apt install dnsutils dnsmasq -y # /etc/dnsmasq.conf server=10.16.2.2 server=10.16.2.3 min-cache-ttl=30 no-resolv listen-address=::1,127.0.0.1 systemctl restart dnsmasq lxc dns: ::1 (and reboot) ``` #### NGINX ```shell cd /etc/nginx/ mv nginx.conf nginx.conf.bkp ln -s /root/amt-jb/nginx.conf . ln -s /root/amt-jb/nginx_amt-jb_proxy_pass.conf . cd sites-enabled rm default ln -s /root/amt-jb/nginx_amt-jb.conf . gpasswd -a www-data root chmod g+x /root && chmod g+x /root/amt-jb && chmod g+x /root/amt-jb/static chmod g+x /root/amt-jb/static/js service nginx restart rm /var/log/nginx/* service nginx restart ``` Confirm uvicorn is running properly ```shell curl -i http://localhost:8000/headers/ ``` ## Telegraf ```shell # influxdata-archive_compat.key GPG fingerprint: # 9D53 9D90 D332 8DC7 D6C8 D3B9 D8FF 8E1F 7DF8 B07E wget -q https://repos.influxdata.com/influxdata-archive_compat.key echo '393e8779c89ac8d958f81f942f9ad7fb82a25e133faddaf92e15b16e6ac9ce4c influxdata-archive_compat.key' | sha256sum -c && cat influxdata-archive_compat.key | gpg --dearmor | tee /etc/apt/trusted.gpg.d/influxdata-archive_compat.gpg > /dev/null echo 'deb [signed-by=/etc/apt/trusted.gpg.d/influxdata-archive_compat.gpg] https://repos.influxdata.com/debian stable main' | tee /etc/apt/sources.list.d/influxdata.list apt-get update && apt-get install telegraf cp /root/amt-jb/telegraf.conf /etc/telegraf/telegraf.conf chown telegraf:telegraf /etc/telegraf/telegraf.conf chmod 644 /etc/telegraf/telegraf.conf # Add the telegraf users to the adm group (for access to /var/log/nginx/) sudo usermod -aG adm telegraf systemctl restart telegraf # sudo -u telegraf telegraf --config /etc/telegraf/telegraf.conf --test ```