Skip to content

SAGUARO-MMA/saguaro_tom

Repository files navigation

SAGUARO TOM

Welcome to the SAGUARO target and observation manager for GW follow-up.

Repositories of Interest:

Installation (for development)

  1. Clone the repository:
  % cd /var/www
  % git clone https://github.com/SAGUARO-MMA/saguaro_tom.git
  1. Copy settings_local.template.py to settings_local.py and edit as you see fit:
  % cd /var/www/saguaro_tom/saguaro_tom
  % cp settings_local.template.py settings_local.py
  % vi settings_local.py
  1. Create virtual environment and install dependencies:
  % cd /var/www/saguaro_tom
  % python3 -m venv venv
  % source venv/bin/activate
  % pip install --upgrade pip
  % pip install -r requirements.txt
  1. Run the development server:
  % python3 manage.py collectstatic # only the first time you start the development server
  % python3 manage.py runserver

Enabling WSGI under Apache2

Enable WSGI within Apache2 in the usual way (there are plenty of web tutorials on this).

Edit saguaro_tom.conf and saguaro_tom-ssl.conf as you see fit to reflect your source code directory and security certificates. You should probably rename 'localhost' to something more suitable. If you do, you will also need to add that name to /etc/hosts and set ALLOWED_HOST in settings_local.py. If you are hosting from a subdomain, you must also set FORCE_SCRIPT_NAME in settings_local.py.

Then (as root) enable the sites:

  % cd /var/www/saguaro_tom
  % cp saguaro_tom.conf /etc/apache2/sites-available/
  % cp saguaro_tom-ssl.conf /etc/apache2/sites-available/
  % cd /etc/apache2/sites-available/
  % apache2ctl configtest
  % a2ensite saguaro_tom.conf
  % a2ensite saguaro_tom-ssl.conf
  % service apache2 restart

Running the alert listener

The alert listener is now integrated into the TOM. It should automatically restart when sand restarts, thanks to this cronjob (run as root):

@reboot sleep 40 && /var/www/saguaro_tom/venv/bin/python /var/www/saguaro_tom/manage.py readstreams > /home/saguaro/alertstreams.log 2>&1

If it does not restart, or you need to restart the listener manually, run the following on sand. First, kill any other instances are running:

pkill -f readstreams

Then run

nohup /var/www/saguaro_tom/venv/bin/python /var/www/saguaro_tom/manage.py readstreams > /home/saguaro/alertstreams.log 2>&1 &

Allowing for asynchronous tasks

We use redis and dramatiq to run asynchronous tasks (e.g., ATLAS forced photometry queries). Redis is installed according to the instructions on its readme. Dramatiq is configured according to the TOM Toolkit documentation. These should automatically restart when sand restarts, thanks to this cronjob (run as root):

@reboot sleep 50 && /usr/local/bin/redis-server > /home/saguaro/redis.log 2>&1
@reboot sleep 60 && /var/www/saguaro_tom/venv/bin/python /var/www/saguaro_tom/manage.py rundramatiq > /home/saguaro/dramatiq.log 2>&1

If either of these does not restart, or you need to restart them manually, run the following on sand. First, kill any other instances are running:

pkill -f redis-server
pkill -f rundramatiq

Then run

nohup redis-server > /home/saguaro/redis.log 2>&1 &
nohup /var/www/saguaro_tom/venv/bin/python /var/www/saguaro_tom/manage.py rundramatiq > /home/saguaro/dramatiq.log 2>&1 &

Other periodic tasks

Several other tasks run every hour as cronjobs (as root):

0 * * * * /var/www/saguaro_tom/venv/bin/python /var/www/saguaro_tom/manage.py report_pointings > /home/saguaro/report_pointings.log 2>&1
0 * * * * /var/www/saguaro_tom/venv/bin/python /var/www/saguaro_tom/manage.py updatestatus > /home/saguaro/observation_status.log 2>&1
0 * * * * /var/www/saguaro_tom/venv/bin/python /var/www/saguaro_tom/manage.py verify_listener > /home/saguaro/verify_listener.log 2>&1
5 * * * * /var/www/saguaro_tom/venv/bin/python /var/www/saguaro_tom/manage.py ingest_tns > /home/saguaro/ingest_tns.log 2>&1

Respectively, these:

  • report survey pointings to the Treasure Map
  • update the statuses of observations scheduled through the TOM (e.g., MMT)
  • verify that the GW alert listener is functioning by checking that we received an alert for the latest event in GraceDB
  • ingest targets from the TNS (the TNS table is updated on the hour, so we run this 10 minutes after)